Skip to content

Commit a70b2cd

Browse files
[3.12] GH-94438: Fix RuntimeWarning for jump tests in test_sys_settrace (GH-111369)
(cherry picked from commit a254120) Co-authored-by: Tian Gao <[email protected]>
1 parent c81ebf5 commit a70b2cd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Lib/test/test_sys_settrace.py

+6-2
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

@@ -1970,6 +1971,9 @@ def run_test(self, func, jumpFrom, jumpTo, expected, error=None,
19701971
stack.enter_context(self.assertRaisesRegex(*error))
19711972
if warning is not None:
19721973
stack.enter_context(self.assertWarnsRegex(*warning))
1974+
else:
1975+
stack.enter_context(warnings.catch_warnings())
1976+
warnings.simplefilter('error')
19731977
func(output)
19741978

19751979
sys.settrace(None)
@@ -2033,7 +2037,7 @@ def test_jump_simple_backwards(output):
20332037
output.append(1)
20342038
output.append(2)
20352039

2036-
@jump_test(1, 4, [5])
2040+
@jump_test(1, 4, [5], warning=(RuntimeWarning, unbound_locals))
20372041
def test_jump_is_none_forwards(output):
20382042
x = None
20392043
if x is None:
@@ -2050,7 +2054,7 @@ def test_jump_is_none_backwards(output):
20502054
output.append(5)
20512055
output.append(6)
20522056

2053-
@jump_test(1, 4, [5])
2057+
@jump_test(2, 4, [5])
20542058
def test_jump_is_not_none_forwards(output):
20552059
x = None
20562060
if x is not None:

0 commit comments

Comments
 (0)