summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_codeop.py
diff options
context:
space:
mode:
authorCheryl Sabella <cheryl.sabella@gmail.com>2020-06-04 23:40:24 (GMT)
committerGitHub <noreply@github.com>2020-06-04 23:40:24 (GMT)
commit052d3fc0907be253cfd64b2c737a0b0aca586011 (patch)
tree3d50f8cb5dbbdab51518e443c456b24f7172aa0d /Lib/test/test_codeop.py
parent3744ed2c9c0b3905947602fc375de49533790cb9 (diff)
downloadcpython-052d3fc0907be253cfd64b2c737a0b0aca586011.zip
cpython-052d3fc0907be253cfd64b2c737a0b0aca586011.tar.gz
cpython-052d3fc0907be253cfd64b2c737a0b0aca586011.tar.bz2
bpo-40807: Show warnings once from codeop._maybe_compile (#20486)
* bpo-40807: Show warnings once from codeop._maybe_compile * Move catch_warnings * news Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Diffstat (limited to 'Lib/test/test_codeop.py')
-rw-r--r--Lib/test/test_codeop.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_codeop.py b/Lib/test/test_codeop.py
index 0c5e362f..45cb1a7 100644
--- a/Lib/test/test_codeop.py
+++ b/Lib/test/test_codeop.py
@@ -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()