mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-135801: Add the module parameter to compile() etc (GH-139652)
Many functions related to compiling or parsing Python code, such as compile(), ast.parse(), symtable.symtable(), and importlib.abc.InspectLoader.source_to_code() now allow to pass the module name used when filtering syntax warnings.
This commit is contained in:
parent
63548b3699
commit
d8e6bdc0d0
47 changed files with 390 additions and 115 deletions
|
|
@ -814,15 +814,26 @@ def test_filter_syntax_warnings_by_module(self):
|
|||
filename = support.findfile('test_import/data/syntax_warnings.py')
|
||||
rc, out, err = assert_python_ok(
|
||||
'-Werror',
|
||||
'-Walways:::test.test_import.data.syntax_warnings',
|
||||
'-Walways:::__main__',
|
||||
'-Werror:::test.test_import.data.syntax_warnings',
|
||||
'-Werror:::syntax_warnings',
|
||||
filename)
|
||||
self.assertEqual(err.count(b': SyntaxWarning: '), 6)
|
||||
|
||||
rc, out, err = assert_python_ok(
|
||||
'-Werror',
|
||||
'-Walways:::syntax_warnings',
|
||||
filename)
|
||||
self.assertEqual(err.count(b': SyntaxWarning: '), 6)
|
||||
def test_zipfile_run_filter_syntax_warnings_by_module(self):
|
||||
filename = support.findfile('test_import/data/syntax_warnings.py')
|
||||
with open(filename, 'rb') as f:
|
||||
source = f.read()
|
||||
with os_helper.temp_dir() as script_dir:
|
||||
zip_name, _ = make_zip_pkg(
|
||||
script_dir, 'test_zip', 'test_pkg', '__main__', source)
|
||||
rc, out, err = assert_python_ok(
|
||||
'-Werror',
|
||||
'-Walways:::__main__',
|
||||
'-Werror:::test_pkg.__main__',
|
||||
os.path.join(zip_name, 'test_pkg')
|
||||
)
|
||||
self.assertEqual(err.count(b': SyntaxWarning: '), 12)
|
||||
|
||||
|
||||
def tearDownModule():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue