Skip to content

bpo-43844: Fix PendingDeprecationWarning in test_lib2to3 #25407

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
Apr 16, 2021
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
12 changes: 8 additions & 4 deletions Lib/lib2to3/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,16 @@ def test_load_grammar_from_subprocess(self):
# different hash randomization seed.
sub_env = dict(os.environ)
sub_env['PYTHONHASHSEED'] = 'random'
subprocess.check_call(
[sys.executable, '-c', """
code = """
from lib2to3.pgen2 import driver as pgen2_driver
pgen2_driver.load_grammar(%r, save=True, force=True)
""" % (grammar_sub_copy,)],
env=sub_env)
""" % (grammar_sub_copy,)
msg = ("lib2to3 package is deprecated and may not be able "
"to parse Python 3.10+")
Copy link
Member Author

Choose a reason for hiding this comment

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

In PR #25406, I added distutils._DEPRECATION_MESSAGE constant to avoid copying the error message. Is it worth it?

cmd = [sys.executable,
f'-Wignore:{msg}:PendingDeprecationWarning',
'-c', code]
subprocess.check_call( cmd, env=sub_env)
self.assertTrue(os.path.exists(pickle_sub_name))

with open(pickle_name, 'rb') as pickle_f_1, \
Expand Down