From ef1fce7c0e89430324ba17749c237fd256657375 Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Wed, 25 Oct 2023 17:52:33 -0700 Subject: [PATCH 1/4] Fix RuntimeWarning for jump tests --- Lib/test/test_sys_settrace.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index 6be9d3f5d0f9a7..f1ac126b7ba598 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -2064,7 +2064,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: @@ -2081,7 +2081,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: From 16a158a372f011f2c30ce89b53670250bbf7c21e Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Wed, 25 Oct 2023 18:05:24 -0700 Subject: [PATCH 2/4] Add warning check --- Lib/test/test_sys_settrace.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index f1ac126b7ba598..57ea7c20111380 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -9,6 +9,7 @@ import asyncio from test.support import import_helper import contextlib +import warnings support.requires_working_socket(module=True) @@ -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.filterwarnings('error') func(output) sys.settrace(None) From 8c4c2d1c9cf9f719d4a240747541dba5ee794a1c Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Wed, 25 Oct 2023 18:17:06 -0700 Subject: [PATCH 3/4] Use simplefilter --- Lib/test/test_sys_settrace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index 57ea7c20111380..1c4c52ff6e4256 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -2004,7 +2004,7 @@ def run_test(self, func, jumpFrom, jumpTo, expected, error=None, stack.enter_context(self.assertWarnsRegex(*warning)) else: stack.enter_context(warnings.catch_warnings()) - warnings.filterwarnings('error') + warnings.simplefilter('error') func(output) sys.settrace(None) From c1af28eab13abd300a6ab31155743c78229f4e26 Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Wed, 25 Oct 2023 18:19:05 -0700 Subject: [PATCH 4/4] Remove spaces --- Lib/test/test_sys_settrace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index 1c4c52ff6e4256..df7dd36274df2e 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -2004,7 +2004,7 @@ def run_test(self, func, jumpFrom, jumpTo, expected, error=None, stack.enter_context(self.assertWarnsRegex(*warning)) else: stack.enter_context(warnings.catch_warnings()) - warnings.simplefilter('error') + warnings.simplefilter('error') func(output) sys.settrace(None)