diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-06-06 08:24:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-06 08:24:45 (GMT) |
commit | c067183605cf84bb1a246635f52827251d0476f8 (patch) | |
tree | 12cb0a05c0f35d7570f95f7f6c3232d2abf6d88a /Lib/test | |
parent | a5d6aba318ead9cc756ba750a70da41f5def3f8f (diff) | |
download | cpython-c067183605cf84bb1a246635f52827251d0476f8.zip cpython-c067183605cf84bb1a246635f52827251d0476f8.tar.gz cpython-c067183605cf84bb1a246635f52827251d0476f8.tar.bz2 |
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 052d3fc0907be253cfd64b2c737a0b0aca586011)
Co-authored-by: Cheryl Sabella <cheryl.sabella@gmail.com>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_codeop.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_codeop.py b/Lib/test/test_codeop.py index 4d52d15..1e57ab9 100644 --- a/Lib/test/test_codeop.py +++ b/Lib/test/test_codeop.py @@ -294,6 +294,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() |