mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-135801: Improve filtering by module in warn_explicit() without module argument (GH-140151)
* Try to match the module name pattern with module names constructed starting from different parent directories of the filename. E.g., for "/path/to/package/module" try to match with "path.to.package.module", "to.package.module", "package.module" and "module". * Ignore trailing "/__init__.py". * Ignore trailing ".pyw" on Windows. * Keep matching with the full filename (without optional ".py" extension) for compatibility. * Only ignore the case of the ".py" extension on Windows.
This commit is contained in:
parent
efc37ba49e
commit
6826166280
13 changed files with 243 additions and 73 deletions
|
|
@ -810,6 +810,19 @@ def test_script_as_dev_fd(self):
|
|||
out, err = p.communicate()
|
||||
self.assertEqual(out, b"12345678912345678912345\n")
|
||||
|
||||
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',
|
||||
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 tearDownModule():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue