issue #20: TestCase subclass with a nicer assertRaises
This commit is contained in:
parent
112f76fe89
commit
bcae62c682
|
@ -28,6 +28,19 @@ def data_path(suffix):
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
class TestCase(unittest.TestCase):
|
||||||
|
def assertRaises(self, exc, func, *args, **kwargs):
|
||||||
|
"""Like regular assertRaises, except return the exception that was
|
||||||
|
raised. Can't use context manager because tests must run on Python2.4"""
|
||||||
|
try:
|
||||||
|
func(*args, **kwargs)
|
||||||
|
except exc, e:
|
||||||
|
return e
|
||||||
|
except BaseException, e:
|
||||||
|
assert 0, '%r raised %r, not %r' % (func, e, exc)
|
||||||
|
assert 0, '%r did not raise %r' % (func, exc)
|
||||||
|
|
||||||
|
|
||||||
class DockerizedSshDaemon(object):
|
class DockerizedSshDaemon(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.docker = docker.from_env()
|
self.docker = docker.from_env()
|
||||||
|
|
Loading…
Reference in New Issue