Commit 40305771 authored by Guido van Rossum's avatar Guido van Rossum

Change verify() function to raise TestFailed, not AssertionError.

(I realize that I didn't really test this, because all the tests
succeed, so verify() never raised an AssertionError -- but the test
suite still succeeds, so I'm not too worried.)
parent 63c8ee4b
...@@ -71,11 +71,11 @@ def findfile(file, here=__file__): ...@@ -71,11 +71,11 @@ def findfile(file, here=__file__):
return file return file
def verify(condition, reason='test failed'): def verify(condition, reason='test failed'):
"""Verify that condition is true. If not, raise an AssertionError. """Verify that condition is true. If not, raise TestFailed.
The optinal argument reason can be given to provide The optinal argument reason can be given to provide
a better error text. a better error text.
""" """
if not condition: if not condition:
raise AssertionError(reason) raise TestFailed(reason)
...@@ -411,7 +411,7 @@ try: ...@@ -411,7 +411,7 @@ try:
except ValueError: except ValueError:
pass pass
else: else:
raise AssertionError, "u'Andr\202'.encode('ascii') failed to raise an exception" raise TestFailed, "u'Andr\202'.encode('ascii') failed to raise an exception"
verify(u'Andr\202 x'.encode('ascii','ignore') == "Andr x") verify(u'Andr\202 x'.encode('ascii','ignore') == "Andr x")
verify(u'Andr\202 x'.encode('ascii','replace') == "Andr? x") verify(u'Andr\202 x'.encode('ascii','replace') == "Andr? x")
...@@ -421,7 +421,7 @@ try: ...@@ -421,7 +421,7 @@ try:
except ValueError: except ValueError:
pass pass
else: else:
raise AssertionError, "unicode('Andr\202') failed to raise an exception" raise TestFailed, "unicode('Andr\202') failed to raise an exception"
verify(unicode('Andr\202 x','ascii','ignore') == u"Andr x") verify(unicode('Andr\202 x','ascii','ignore') == u"Andr x")
verify(unicode('Andr\202 x','ascii','replace') == u'Andr\uFFFD x') verify(unicode('Andr\202 x','ascii','replace') == u'Andr\uFFFD x')
...@@ -443,7 +443,7 @@ for encoding in ( ...@@ -443,7 +443,7 @@ for encoding in (
): ):
try: try:
verify(unicode(u.encode(encoding),encoding) == u) verify(unicode(u.encode(encoding),encoding) == u)
except AssertionError: except TestFailed:
print '*** codec "%s" failed round-trip' % encoding print '*** codec "%s" failed round-trip' % encoding
except ValueError,why: except ValueError,why:
print '*** codec for "%s" failed: %s' % (encoding, why) print '*** codec for "%s" failed: %s' % (encoding, why)
...@@ -454,7 +454,7 @@ for encoding in ( ...@@ -454,7 +454,7 @@ for encoding in (
): ):
try: try:
verify(unicode(u.encode(encoding),encoding) == u) verify(unicode(u.encode(encoding),encoding) == u)
except AssertionError: except TestFailed:
print '*** codec "%s" failed round-trip' % encoding print '*** codec "%s" failed round-trip' % encoding
except ValueError,why: except ValueError,why:
print '*** codec for "%s" failed: %s' % (encoding, why) print '*** codec for "%s" failed: %s' % (encoding, why)
...@@ -488,7 +488,7 @@ for encoding in ( ...@@ -488,7 +488,7 @@ for encoding in (
): ):
try: try:
verify(unicode(s,encoding).encode(encoding) == s) verify(unicode(s,encoding).encode(encoding) == s)
except AssertionError: except TestFailed:
print '*** codec "%s" failed round-trip' % encoding print '*** codec "%s" failed round-trip' % encoding
except ValueError,why: except ValueError,why:
print '*** codec for "%s" failed: %s' % (encoding, why) print '*** codec for "%s" failed: %s' % (encoding, why)
...@@ -518,7 +518,7 @@ for encoding in ( ...@@ -518,7 +518,7 @@ for encoding in (
): ):
try: try:
verify(unicode(s,encoding).encode(encoding) == s) verify(unicode(s,encoding).encode(encoding) == s)
except AssertionError: except TestFailed:
print '*** codec "%s" failed round-trip' % encoding print '*** codec "%s" failed round-trip' % encoding
except ValueError,why: except ValueError,why:
print '*** codec for "%s" failed: %s' % (encoding, why) print '*** codec for "%s" failed: %s' % (encoding, why)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment