summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_parser.py')
-rw-r--r--Lib/test/test_parser.py16
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):