[Python-checkins] cpython (merge 3.2 -> default): #8414: merge with 3.2.
ezio.melotti
python-checkins at python.org
Fri Dec 2 17:24:12 CET 2011
http://hg.python.org/cpython/rev/47afbb2033aa
changeset: 73808:47afbb2033aa
parent: 73805:7e37598a25a6
parent: 73807:1efefeda00a7
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Fri Dec 02 18:23:54 2011 +0200
summary:
#8414: merge with 3.2.
files:
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
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -500,13 +500,35 @@
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
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list