summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sys_settrace.py
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2023-10-26 18:47:51 (GMT)
committerGitHub <noreply@github.com>2023-10-26 18:47:51 (GMT)
commita254120f2f1dd99fa64f12594d1ed19c67df7d64 (patch)
tree1a41673cb728ecca84aa08adac4ea03c9b8c1c37 /Lib/test/test_sys_settrace.py
parentb468538d356552f0242763fe44a17b1939e8bd55 (diff)
downloadcpython-a254120f2f1dd99fa64f12594d1ed19c67df7d64.zip
cpython-a254120f2f1dd99fa64f12594d1ed19c67df7d64.tar.gz
cpython-a254120f2f1dd99fa64f12594d1ed19c67df7d64.tar.bz2
GH-94438: Fix RuntimeWarning for jump tests in test_sys_settrace (GH-111341)
Diffstat (limited to 'Lib/test/test_sys_settrace.py')
-rw-r--r--Lib/test/test_sys_settrace.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py
index 6be9d3f..df7dd36 100644
--- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -9,6 +9,7 @@ from functools import wraps
import asyncio
from test.support import import_helper
import contextlib
+import warnings
support.requires_working_socket(module=True)
@@ -2001,6 +2002,9 @@ class JumpTestCase(unittest.TestCase):
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)
@@ -2064,7 +2068,7 @@ class JumpTestCase(unittest.TestCase):
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:
@@ -2081,7 +2085,7 @@ class JumpTestCase(unittest.TestCase):
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: