return file
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
a better error text.
"""
if not condition:
- raise AssertionError(reason)
+ raise TestFailed(reason)
except ValueError:
pass
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','replace') == "Andr? x")
except ValueError:
pass
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','replace') == u'Andr\uFFFD x')
):
try:
verify(unicode(u.encode(encoding),encoding) == u)
- except AssertionError:
+ except TestFailed:
print '*** codec "%s" failed round-trip' % encoding
except ValueError,why:
print '*** codec for "%s" failed: %s' % (encoding, why)
):
try:
verify(unicode(u.encode(encoding),encoding) == u)
- except AssertionError:
+ except TestFailed:
print '*** codec "%s" failed round-trip' % encoding
except ValueError,why:
print '*** codec for "%s" failed: %s' % (encoding, why)
):
try:
verify(unicode(s,encoding).encode(encoding) == s)
- except AssertionError:
+ except TestFailed:
print '*** codec "%s" failed round-trip' % encoding
except ValueError,why:
print '*** codec for "%s" failed: %s' % (encoding, why)
):
try:
verify(unicode(s,encoding).encode(encoding) == s)
- except AssertionError:
+ except TestFailed:
print '*** codec "%s" failed round-trip' % encoding
except ValueError,why:
print '*** codec for "%s" failed: %s' % (encoding, why)