Enclose with try...finally
@@ -92,7 +92,9 @@ def fix_random():
@functools.wraps(impl)
def test_func(self, *args, **kw):
_setup_random()
+ try:
impl(self, *args, **kw)
+ finally:
_teardown_random()
return test_func
elif isinstance(impl, type) and issubclass(impl, unittest.TestCase):
@@ -107,7 +109,9 @@ def fix_random():
def wrap_tearDown(f):
def func(self):
+ try:
f(self)
+ finally:
_teardown_random()
return func
