diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-12-02 16:23:54 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-12-02 16:23:54 (GMT) |
commit | b3d188f7792d037ee8b10d81bc26f9aeadbf8bbd (patch) | |
tree | 6c1b8b77062e564eb11069d2fc411a9132b83610 /Lib/test/test_grammar.py | |
parent | 47862d4c0ea5dc75c2f094f071847aca378dab9d (diff) | |
parent | 6cc5bf765688fc1fa6bc7b634562c411e6495fde (diff) | |
download | cpython-b3d188f7792d037ee8b10d81bc26f9aeadbf8bbd.zip cpython-b3d188f7792d037ee8b10d81bc26f9aeadbf8bbd.tar.gz cpython-b3d188f7792d037ee8b10d81bc26f9aeadbf8bbd.tar.bz2 |
#8414: merge with 3.2.
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r-- | Lib/test/test_grammar.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index 32dc15e..eff763e 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -500,13 +500,35 @@ class GrammarTests(unittest.TestCase): assert 1, 1 assert lambda x:x assert 1, lambda x:x+1 + + try: + assert True + except AssertionError as e: + self.fail("'assert True' should not have raised an AssertionError") + + try: + assert True, 'this should always pass' + except AssertionError as e: + self.fail("'assert True, msg' should not have " + "raised an AssertionError") + + # these tests fail if python is run with -O, so check __debug__ + @unittest.skipUnless(__debug__, "Won't work if __debug__ is False") + def testAssert2(self): try: assert 0, "msg" except AssertionError as e: self.assertEqual(e.args[0], "msg") else: - if __debug__: - self.fail("AssertionError not raised by assert 0") + self.fail("AssertionError not raised by assert 0") + + try: + assert False + except AssertionError as e: + self.assertEqual(len(e.args), 0) + else: + self.fail("AssertionError not raised by 'assert False'") + ### compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef # Tested below |