Skip to content

Commit

Permalink
pythonGH-94438: Fix RuntimeWarning for jump tests in test_sys_settrace (
Browse files Browse the repository at this point in the history
  • Loading branch information
gaogaotiantian authored Oct 26, 2023
1 parent b468538 commit a254120
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Lib/test/test_sys_settrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import asyncio
from test.support import import_helper
import contextlib
import warnings

support.requires_working_socket(module=True)

Expand Down Expand Up @@ -2001,6 +2002,9 @@ def run_test(self, func, jumpFrom, jumpTo, expected, error=None,
stack.enter_context(self.assertRaisesRegex(*error))
if warning is not None:
stack.enter_context(self.assertWarnsRegex(*warning))
else:
stack.enter_context(warnings.catch_warnings())
warnings.simplefilter('error')
func(output)

sys.settrace(None)
Expand Down Expand Up @@ -2064,7 +2068,7 @@ def test_jump_simple_backwards(output):
output.append(1)
output.append(2)

@jump_test(1, 4, [5])
@jump_test(1, 4, [5], warning=(RuntimeWarning, unbound_locals))
def test_jump_is_none_forwards(output):
x = None
if x is None:
Expand All @@ -2081,7 +2085,7 @@ def test_jump_is_none_backwards(output):
output.append(5)
output.append(6)

@jump_test(1, 4, [5])
@jump_test(2, 4, [5])
def test_jump_is_not_none_forwards(output):
x = None
if x is not None:
Expand Down

0 comments on commit a254120

Please sign in to comment.