summaryrefslogtreecommitdiff
path: root/testtools/tests/test_fixturesupport.py
diff options
context:
space:
mode:
Diffstat (limited to 'testtools/tests/test_fixturesupport.py')
-rw-r--r--testtools/tests/test_fixturesupport.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/testtools/tests/test_fixturesupport.py b/testtools/tests/test_fixturesupport.py
index 2ccd1e8..e309045 100644
--- a/testtools/tests/test_fixturesupport.py
+++ b/testtools/tests/test_fixturesupport.py
@@ -10,6 +10,7 @@ from testtools import (
content_type,
)
from testtools.compat import _b, _u
+from testtools.matchers import Contains
from testtools.testresult.doubles import (
ExtendedTestResult,
)
@@ -112,6 +113,32 @@ class TestFixtureSupport(TestCase):
self.assertEqual(['content', 'traceback'], sorted(details))
self.assertEqual('foobar', ''.join(details['content'].iter_text()))
+ def test_useFixture_original_exception_raised_if_gather_details_fails(self):
+ # In bug #1368440 it was reported that when a fixture fails setUp
+ # and gather_details errors on it, then the original exception that
+ # failed is not reported.
+ class BrokenFixture(fixtures.Fixture):
+ def getDetails(self):
+ raise AttributeError("getDetails broke")
+ def setUp(self):
+ fixtures.Fixture.setUp(self)
+ raise Exception("setUp broke")
+ fixture = BrokenFixture()
+ class SimpleTest(TestCase):
+ def test_foo(self):
+ self.useFixture(fixture)
+ result = ExtendedTestResult()
+ SimpleTest('test_foo').run(result)
+ self.assertEqual('addError', result._events[-2][0])
+ details = result._events[-2][2]
+ self.assertEqual(['traceback', 'traceback-1'], sorted(details))
+ self.assertThat(
+ ''.join(details['traceback'].iter_text()),
+ Contains('setUp broke'))
+ self.assertThat(
+ ''.join(details['traceback-1'].iter_text()),
+ Contains('getDetails broke'))
+
def test_suite():
from unittest import TestLoader