cpython: bcfb499338c1 (original) (raw)
Mercurial > cpython
changeset 73806:bcfb499338c1 2.7
#8414: add more tests for "assert". Initial patch by Gregory Nofi. [#8414]
Ezio Melotti ezio.melotti@gmail.com | |
---|---|
date | Fri, 02 Dec 2011 18:17:30 +0200 |
parents | 3ecddf168f1f |
children | d9e918c8d9d6 |
files | Lib/test/test_grammar.py |
diffstat | 1 files changed, 24 insertions(+), 2 deletions(-)[+] [-] Lib/test/test_grammar.py 26 |
line wrap: on
line diff
--- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -551,13 +551,35 @@ hello world assert 1, 1 assert lambda x:x assert 1, lambda x:x+1 +
try:[](#l1.8)
assert True[](#l1.9)
except AssertionError as e:[](#l1.10)
self.fail("'assert True' should not have raised an AssertionError")[](#l1.11)
try:[](#l1.13)
assert True, 'this should always pass'[](#l1.14)
except AssertionError as e:[](#l1.15)
self.fail("'assert True, msg' should not have "[](#l1.16)
"raised an AssertionError")[](#l1.17)
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, e: self.assertEqual(e.args[0], "msg") else:
if __debug__:[](#l1.27)
self.fail("AssertionError not raised by assert 0")[](#l1.28)
self.fail("AssertionError not raised by assert 0")[](#l1.29)
try:[](#l1.31)
assert False[](#l1.32)
except AssertionError as e:[](#l1.33)
self.assertEqual(len(e.args), 0)[](#l1.34)
else:[](#l1.35)
self.fail("AssertionError not raised by 'assert False'")[](#l1.36)
+ ### compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef # Tested below