Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(277671)

Delta Between Two Patch Sets: Lib/test/test_grammar.py

Issue 11682: PEP 380 reference implementation for 3.3
Left Patch Set: Created 7 years, 9 months ago
Right Patch Set: Created 7 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 # Python test set -- part 1, grammar. 1 # Python test set -- part 1, grammar.
2 # This just tests whether the parser accepts them all. 2 # This just tests whether the parser accepts them all.
3 3
4 from test.support import run_unittest, check_syntax_error 4 from test.support import run_unittest, check_syntax_error
5 import unittest 5 import unittest
6 import sys 6 import sys
7 # testing import * 7 # testing import *
8 from sys import * 8 from sys import *
9 9
10 10
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 def f(): 525 def f():
526 nonlocal x 526 nonlocal x
527 nonlocal x, y 527 nonlocal x, y
528 528
529 def test_assert(self): 529 def test_assert(self):
530 # assertTruestmt: 'assert' test [',' test] 530 # assertTruestmt: 'assert' test [',' test]
531 assert 1 531 assert 1
532 assert 1, 1 532 assert 1, 1
533 assert lambda x:x 533 assert lambda x:x
534 assert 1, lambda x:x+1 534 assert 1, lambda x:x+1
535
536 try:
537 assert True
538 except AssertionError as e:
539 self.fail("'assert True' should not have raised an AssertionError")
540
541 try:
542 assert True, 'this should always pass'
543 except AssertionError as e:
544 self.fail("'assert True, msg' should not have "
545 "raised an AssertionError")
546
547 # these tests fail if python is run with -O, so check __debug__
548 @unittest.skipUnless(__debug__, "Won't work if __debug__ is False")
549 def testAssert2(self):
535 try: 550 try:
536 assert 0, "msg" 551 assert 0, "msg"
537 except AssertionError as e: 552 except AssertionError as e:
538 self.assertEqual(e.args[0], "msg") 553 self.assertEqual(e.args[0], "msg")
539 else: 554 else:
540 if __debug__: 555 self.fail("AssertionError not raised by assert 0")
541 self.fail("AssertionError not raised by assert 0") 556
557 try:
558 assert False
559 except AssertionError as e:
560 self.assertEqual(len(e.args), 0)
561 else:
562 self.fail("AssertionError not raised by 'assert False'")
563
542 564
543 ### compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | cl assdef 565 ### compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | cl assdef
544 # Tested below 566 # Tested below
545 567
546 def test_if(self): 568 def test_if(self):
547 # 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] 569 # 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
548 if 1: pass 570 if 1: pass
549 if 1: pass 571 if 1: pass
550 else: pass 572 else: pass
551 if 0: pass 573 if 0: pass
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 self.assertTrue(False is (2 is 3)) 977 self.assertTrue(False is (2 is 3))
956 self.assertFalse((False is 2) is 3) 978 self.assertFalse((False is 2) is 3)
957 self.assertFalse(False is 2 is 3) 979 self.assertFalse(False is 2 is 3)
958 980
959 981
960 def test_main(): 982 def test_main():
961 run_unittest(TokenTests, GrammarTests) 983 run_unittest(TokenTests, GrammarTests)
962 984
963 if __name__ == '__main__': 985 if __name__ == '__main__':
964 test_main() 986 test_main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+