Skip to content

Commit 471870f

Browse files
authored
bpo-43844: Fix PendingDeprecationWarning in test_lib2to3 (GH-25407)
1 parent 69ca32e commit 471870f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Lib/lib2to3/tests/test_parser.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,16 @@ def test_load_grammar_from_subprocess(self):
8484
# different hash randomization seed.
8585
sub_env = dict(os.environ)
8686
sub_env['PYTHONHASHSEED'] = 'random'
87-
subprocess.check_call(
88-
[sys.executable, '-c', """
87+
code = """
8988
from lib2to3.pgen2 import driver as pgen2_driver
9089
pgen2_driver.load_grammar(%r, save=True, force=True)
91-
""" % (grammar_sub_copy,)],
92-
env=sub_env)
90+
""" % (grammar_sub_copy,)
91+
msg = ("lib2to3 package is deprecated and may not be able "
92+
"to parse Python 3.10+")
93+
cmd = [sys.executable,
94+
f'-Wignore:{msg}:PendingDeprecationWarning',
95+
'-c', code]
96+
subprocess.check_call( cmd, env=sub_env)
9397
self.assertTrue(os.path.exists(pickle_sub_name))
9498

9599
with open(pickle_name, 'rb') as pickle_f_1, \

0 commit comments

Comments
 (0)