summaryrefslogtreecommitdiff
path: root/fixtures/tests
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2015-06-30 12:58:56 +1200
committerRobert Collins <robertc@robertcollins.net>2015-06-30 13:00:55 +1200
commit3f965dd8a9d60950a6d24be2a2c87a24b6f82196 (patch)
treeb5dd3181360902f571b7894e284fb093a14e8884 /fixtures/tests
parent5355689a2aa85e58b29e3c88e32ff9521dc5bd17 (diff)
downloadfixtures-git-3f965dd8a9d60950a6d24be2a2c87a24b6f82196.tar.gz
Handle BaseException resource leaks as well.
The change to handle resource leaks incorrectly ignored BaseException - e.g. KeyboardInterrupt.
Diffstat (limited to 'fixtures/tests')
-rw-r--r--fixtures/tests/test_fixture.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/fixtures/tests/test_fixture.py b/fixtures/tests/test_fixture.py
index 737ae41..cf3ed3c 100644
--- a/fixtures/tests/test_fixture.py
+++ b/fixtures/tests/test_fixture.py
@@ -257,6 +257,21 @@ class TestFixture(testtools.TestCase):
self.assertEqual(fixtures.SetupError, e.args[2][0])
self.assertEqual('stuff', e.args[2][1].args[0]['log'].as_text())
+ def test_setup_failures_with_base_exception(self):
+ # when _setUp fails with a BaseException (or subclass thereof) that
+ # exception is propogated as is, but we still call cleanups etc.
+ class MyBase(BaseException):pass
+ log = []
+ class Subclass(fixtures.Fixture):
+ def _setUp(self):
+ self.addDetail('log', text_content('stuff'))
+ self.addCleanup(log.append, 'cleaned')
+ raise MyBase('fred')
+ f = Subclass()
+ e = self.assertRaises(MyBase, f.setUp)
+ self.assertRaises(TypeError, f.cleanUp)
+ self.assertEqual(['cleaned'], log)
+
class TestFunctionFixture(testtools.TestCase):