]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-96276: suppress SyntaxWarning in test_compile (GH-96277)
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
Thu, 25 Aug 2022 21:23:06 +0000 (22:23 +0100)
committerGitHub <noreply@github.com>
Thu, 25 Aug 2022 21:23:06 +0000 (22:23 +0100)
Lib/test/test_compile.py

index c64e4e55f4445afc251de67c995e0cdf637d2e93..d7b78f686ef88d179d44d2b2855ffdeb0748755a 100644 (file)
@@ -8,6 +8,7 @@ import _ast
 import tempfile
 import types
 import textwrap
+import warnings
 from test import support
 from test.support import script_helper, requires_debug_ranges
 from test.support.os_helper import FakePath
@@ -1231,7 +1232,9 @@ f(
             with self.subTest(body):
                 namespace = {}
                 source = textwrap.dedent(source_template.format(body))
-                exec(source, namespace)
+                with warnings.catch_warnings():
+                    warnings.simplefilter('ignore', SyntaxWarning)
+                    exec(source, namespace)
                 code = namespace["f"].__code__
                 self.assertOpcodeSourcePositionIs(
                     code,