mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-22 09:29:43 +00:00
15 lines
430 B
Python
15 lines
430 B
Python
|
def assert_raises(excClass, callableObj, *args, **kwargs):
|
||
|
"""
|
||
|
Like unittest.TestCase.assertRaises, but returns the exception.
|
||
|
"""
|
||
|
try:
|
||
|
callableObj(*args, **kwargs)
|
||
|
except excClass as e:
|
||
|
return e
|
||
|
else:
|
||
|
if hasattr(excClass, '__name__'):
|
||
|
excName = excClass.__name__
|
||
|
else:
|
||
|
excName = str(excClass)
|
||
|
raise AssertionError("%s not raised" % excName)
|