gh-96276: suppress SyntaxWarning in test_compile (GH-96277)

This commit is contained in:
Irit Katriel 2022-08-25 22:23:06 +01:00 committed by GitHub
parent 1288097088
commit 1e743616ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,6 +8,7 @@
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 @@ def 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,