diff options
author | tyomitch <tyomitch@gmail.com> | 2019-04-03 05:12:07 (GMT) |
---|---|---|
committer | Pablo Galindo <Pablogsal@gmail.com> | 2019-04-03 05:12:07 (GMT) |
commit | cb0748d3939c31168ab5d3b80e3677494497d5e3 (patch) | |
tree | 8debb59a0158afc0dd194ea161ca2669e7bdcef7 /Lib/test | |
parent | 76b387bf7402863c5e64e3459e2f91ddc3b9d2d3 (diff) | |
download | cpython-cb0748d3939c31168ab5d3b80e3677494497d5e3.zip cpython-cb0748d3939c31168ab5d3b80e3677494497d5e3.tar.gz cpython-cb0748d3939c31168ab5d3b80e3677494497d5e3.tar.bz2 |
bpo-36440: include node names in ParserError messages, instead of numeric IDs (GH-12565)
The error messages in the parser module are referring to numeric IDs for the nodes. To improve readability, use the node names when reporting errors.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_parser.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index bfa0a5a..ff587c3 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -749,6 +749,22 @@ class IllegalSyntaxTestCase(unittest.TestCase): with self.assertRaises(UnicodeEncodeError): parser.sequence2st(tree) + def test_invalid_node_id(self): + tree = (257, (269, (-7, ''))) + self.check_bad_tree(tree, "negative node id") + tree = (257, (269, (99, ''))) + self.check_bad_tree(tree, "invalid token id") + tree = (257, (269, (9999, (0, '')))) + self.check_bad_tree(tree, "invalid symbol id") + + def test_ParserError_message(self): + try: + parser.sequence2st((257,(269,(257,(0,''))))) + except parser.ParserError as why: + self.assertIn("compound_stmt", str(why)) # Expected + self.assertIn("file_input", str(why)) # Got + + class CompileTestCase(unittest.TestCase): |