8000 gh-96276: suppress SyntaxWarning in test_compile by iritkatriel · Pull Request #96277 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-96276: suppress SyntaxWarning in test_compile #96277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there value in asserting that the warning is emitted rather than just ignoring it? (Or is that already tested by another test elsewhere?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's covered in test_grammar:

check('[[i for i in range(5)] (3, 4)]')

exec(source, namespace)
code = namespace["f"].__code__
self.assertOpcodeSourcePositionIs(
code,
Expand Down
0