diff options
author | Jonathan Lange <jml@mumak.net> | 2015-11-30 10:22:54 +0000 |
---|---|---|
committer | Jonathan Lange <jml@mumak.net> | 2015-11-30 10:22:54 +0000 |
commit | dfceeab9520fa331b8b4b7a5d412fd1fc8a8263a (patch) | |
tree | 1741aed03652ae26998fcd7f99754bc22b52a560 | |
parent | facacbd9bcb19310688a492d87c7d789c1d0e9bc (diff) | |
download | testtools-dfceeab9520fa331b8b4b7a5d412fd1fc8a8263a.tar.gz |
Simplify cleanup code
-rw-r--r-- | testtools/testcase.py | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/testtools/testcase.py b/testtools/testcase.py index d219175..394e1d2 100644 --- a/testtools/testcase.py +++ b/testtools/testcase.py @@ -636,19 +636,16 @@ class TestCase(unittest.TestCase): :raises ValueError: If the base class tearDown is not called, a ValueError is raised. """ - try: - return self.tearDown() - finally: - if not self.__teardown_called: - raise ValueError( - "In File: %s\n" - "TestCase.tearDown was not called. Have you upcalled all the " - "way up the hierarchy from your tearDown? e.g. Call " - "super(%s, self).tearDown() from your tearDown()." - % (sys.modules[self.__class__.__module__].__file__, - self.__class__.__name__)) - self.__setup_called = False - self.__teardown_called = False + ret = self.tearDown() + if not self.__teardown_called: + raise ValueError( + "In File: %s\n" + "TestCase.tearDown was not called. Have you upcalled all the " + "way up the hierarchy from your tearDown? e.g. Call " + "super(%s, self).tearDown() from your tearDown()." + % (sys.modules[self.__class__.__module__].__file__, + self.__class__.__name__)) + return ret def _get_test_method(self): method_name = getattr(self, '_testMethodName') |