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
1 changed files with 4 additions and 1 deletions

View 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,