mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
bpo-40807: Show warnings once from codeop._maybe_compile (GH-20486)
* bpo-40807: Show warnings once from codeop._maybe_compile
* Move catch_warnings
* news
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit 052d3fc090
)
Co-authored-by: Cheryl Sabella <cheryl.sabella@gmail.com>
This commit is contained in:
parent
e4e5ec18e2
commit
3dfe549bfa
3 changed files with 19 additions and 8 deletions
|
@ -303,6 +303,11 @@ class CodeopTests(unittest.TestCase):
|
|||
self.assertNotEqual(compile_command("a = 1\n", "abc").co_filename,
|
||||
compile("a = 1\n", "def", 'single').co_filename)
|
||||
|
||||
def test_warning(self):
|
||||
# Test that the warning is only returned once.
|
||||
with support.check_warnings((".*literal", SyntaxWarning)) as w:
|
||||
compile_command("0 is 0")
|
||||
self.assertEqual(len(w.warnings), 1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue