| OLD | NEW |
| 1 import parser | 1 import parser |
| 2 import unittest | 2 import unittest |
| 3 import sys | 3 import sys |
| 4 import operator | 4 import operator |
| 5 from test import support | 5 from test import support |
| 6 | 6 |
| 7 # | 7 # |
| 8 # First, we test that we can generate trees from valid source fragments, | 8 # First, we test that we can generate trees from valid source fragments, |
| 9 # and that these valid trees are indeed allowed by the tree-loading side | 9 # and that these valid trees are indeed allowed by the tree-loading side |
| 10 # of the parser module. | 10 # of the parser module. |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 (6, '', 2, -1), | 293 (6, '', 2, -1), |
| 294 (4, '', 2, -1), | 294 (4, '', 2, -1), |
| 295 (0, '', 2, -1)], | 295 (0, '', 2, -1)], |
| 296 terminals) | 296 terminals) |
| 297 | 297 |
| 298 def test_extended_unpacking(self): | 298 def test_extended_unpacking(self): |
| 299 self.check_suite("*a = y") | 299 self.check_suite("*a = y") |
| 300 self.check_suite("x, *b, = m") | 300 self.check_suite("x, *b, = m") |
| 301 self.check_suite("[*a, *b] = y") | 301 self.check_suite("[*a, *b] = y") |
| 302 self.check_suite("for [*x, b] in x: pass") | 302 self.check_suite("for [*x, b] in x: pass") |
| 303 |
| 304 def test_raise_statement(self): |
| 305 self.check_suite("raise\n") |
| 306 self.check_suite("raise e\n") |
| 307 self.check_suite("try:\n" |
| 308 " suite\n" |
| 309 "except Exception as e:\n" |
| 310 " raise ValueError from e\n") |
| 303 | 311 |
| 304 | 312 |
| 305 # | 313 # |
| 306 # Second, we take *invalid* trees and make sure we get ParserError | 314 # Second, we take *invalid* trees and make sure we get ParserError |
| 307 # rejections for them. | 315 # rejections for them. |
| 308 # | 316 # |
| 309 | 317 |
| 310 class IllegalSyntaxTestCase(unittest.TestCase): | 318 class IllegalSyntaxTestCase(unittest.TestCase): |
| 311 | 319 |
| 312 def check_bad_tree(self, tree, label): | 320 def check_bad_tree(self, tree, label): |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 IllegalSyntaxTestCase, | 670 IllegalSyntaxTestCase, |
| 663 CompileTestCase, | 671 CompileTestCase, |
| 664 ParserStackLimitTestCase, | 672 ParserStackLimitTestCase, |
| 665 STObjectTestCase, | 673 STObjectTestCase, |
| 666 OtherParserCase, | 674 OtherParserCase, |
| 667 ) | 675 ) |
| 668 | 676 |
| 669 | 677 |
| 670 if __name__ == "__main__": | 678 if __name__ == "__main__": |
| 671 test_main() | 679 test_main() |
| OLD | NEW |