Index: Lib/test/test_grammar.py =================================================================== --- Lib/test/test_grammar.py (revision 80323) +++ Lib/test/test_grammar.py (working copy) @@ -544,7 +544,8 @@ if '__builtins__' in l: del l['__builtins__'] if (g, l) != ({'a':1}, {'b':2}): self.fail('exec ... in g (%s), l (%s)' %(g,l)) - + + @unittest.skipUnless(__debug__, "Won't work and is irrelevant if __debug__ is False") def testAssert(self): # assertTruestmt: 'assert' test [',' test] assert 1 @@ -553,12 +554,29 @@ assert 1, lambda x:x+1 try: assert 0, "msg" - except AssertionError, e: + except AssertionError as e: + self.assertEqual(len(e.args), 1) 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 with message") + + try: + assert False + except AssertionError as e: + self.assertEqual(len(e.args), 0) + else: + self.fail("AssertionError not raised by 'assert False'") + + 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") + ### compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef # Tested below