← Back to team overview

testtools-dev team mailing list archive

[Merge] lp:~kampka/testtools/test-to-fixture into lp:testtools

 

Christian Kampka has proposed merging lp:~kampka/testtools/test-to-fixture into lp:testtools.

Requested reviews:
  testtools developers (testtools-dev)

For more details, see:
https://code.launchpad.net/~kampka/testtools/test-to-fixture/+merge/65034

Occasionally I find it useful to have more control over the test within the fixture, e.g. in case something unexpected happens during fixture setup. In order to do so, an instance of the testcase should be available to the fixture.
-- 
https://code.launchpad.net/~kampka/testtools/test-to-fixture/+merge/65034
Your team testtools developers is requested to review the proposed merge of lp:~kampka/testtools/test-to-fixture into lp:testtools.
=== modified file 'testtools/testcase.py'
--- testtools/testcase.py	2011-05-27 17:00:32 +0000
+++ testtools/testcase.py	2011-06-17 16:23:24 +0000
@@ -549,6 +549,7 @@
            it.
         """
         try:
+            fixture.test = self
             fixture.setUp()
         except:
             gather_details(fixture, self)

=== modified file 'testtools/tests/test_fixturesupport.py'
--- testtools/tests/test_fixturesupport.py	2011-05-25 15:03:35 +0000
+++ testtools/tests/test_fixturesupport.py	2011-06-17 16:23:24 +0000
@@ -110,6 +110,10 @@
         self.assertEqual(['content', 'traceback'], sorted(details))
         self.assertEqual('foobar', ''.join(details['content'].iter_text()))
 
+    def test_attacheTestToFixture(self):
+        fixture = LoggingFixture()
+        self.useFixture(fixture)
+        self.assertEqual(fixture.test, self)
 
 def test_suite():
     from unittest import TestLoader


Follow ups