E615 GH-94438: Fix RuntimeWarning for jump tests in test_sys_settrace (GH-… · python/cpython@a254120 · GitHub
[go: up one dir, main page]

Skip to content

Commit a254120

Browse files
GH-94438: Fix RuntimeWarning for jump tests in test_sys_settrace (GH-111341)
1 parent b468538 commit a254120

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Lib/test/test_sys_settrace.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import asyncio
1010
from test.support import import_helper
1111
import contextlib
12+
import warnings
1213

1314
support.requires_working_socket(module=True)
1415

@@ -2001,6 +2002,9 @@ def run_test(self, func, jumpFrom, jumpTo, expected, error=None,
20012002
stack.enter_context(self.assertRaisesRegex(*error))
20022003
if warning is not None:
20032004
stack.enter_context(self.assertWarnsRegex(*warning))
2005+
else:
2006+
stack.enter_context(warnings.catch_warnings())
2007+
warnings.simplefilter('error')
20042008
func(output)
20052009

20062010
sys.settrace(None)
@@ -2064,7 +2068,7 @@ def test_jump_simple_backwards(output):
20642068
output.append(1)
20652069
output.append(2)
20662070

2067-
@jump_test(1, 4, [5])
2071+
@jump_test(1, 4, [5], warning=(RuntimeWarning, unbound_locals))
20682072
def test_jump_is_none_forwards(output):
20692073
x = None
20702074
if x is None:
@@ -2081,7 +2085,7 @@ def test_jump_is_none_backwards(output):
20812085
output.append(5)
20822086
output.append(6)
20832087

2084-
@jump_test(1, 4, [5])
2088+
@jump_test(2, 4, [5])
20852089
def test_jump_is_not_none_forwards(output):
20862090
x = None
20872091
if x is not None:

0 commit comments

Comments
 (0)
0