diff options
author | Robert Collins <robertc@robertcollins.net> | 2011-05-05 10:08:24 +1200 |
---|---|---|
committer | Robert Collins <robertc@robertcollins.net> | 2011-05-05 10:08:24 +1200 |
commit | 4bc640b4c3eddd14770eb3a3cb2e6f6c75ed058d (patch) | |
tree | 444ed353ecf31f3a1ce38d0fbb59c29600978add | |
parent | 07559ed10387f04019d2c61ce7c14fdd1b9528b7 (diff) | |
parent | 7fe5a514f2b99b548af39a555658fd2276dbd44c (diff) | |
download | testresources-git-4bc640b4c3eddd14770eb3a3cb2e6f6c75ed058d.tar.gz |
* super() is now called from ResourcedTestCase fixing a long standing issue
with using it as a mix-in in Python 2.4 and above. (Tim Cole, #771505)
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | lib/testresources/__init__.py | 4 | ||||
-rw-r--r-- | lib/testresources/tests/test_optimising_test_suite.py | 6 | ||||
-rw-r--r-- | lib/testresources/tests/test_resourced_test_case.py | 30 |
4 files changed, 37 insertions, 6 deletions
@@ -11,6 +11,9 @@ IMPROVEMENTS * Added ``testresources.FixtureResource`` to wrap ``fixtures.Fixture`` instances. (Robert Collins) +* super() is now called from ResourcedTestCase fixing a long standing issue + with using it as a mix-in in Python 2.4 and above. (Tim Cole, #771505) + 0.2.4 ----- diff --git a/lib/testresources/__init__.py b/lib/testresources/__init__.py index 668a3e3..9b12931 100644 --- a/lib/testresources/__init__.py +++ b/lib/testresources/__init__.py @@ -674,7 +674,7 @@ class ResourcedTestCase(unittest.TestCase): resources = [] def setUp(self): - unittest.TestCase.setUp(self) + super(ResourcedTestCase, self).setUp() self.setUpResources() def setUpResources(self): @@ -682,7 +682,7 @@ class ResourcedTestCase(unittest.TestCase): def tearDown(self): self.tearDownResources() - unittest.TestCase.tearDown(self) + super(ResourcedTestCase, self).tearDown() def tearDownResources(self): tearDownResources(self, self.resources, _get_result()) diff --git a/lib/testresources/tests/test_optimising_test_suite.py b/lib/testresources/tests/test_optimising_test_suite.py index 477cd1e..cf13755 100644 --- a/lib/testresources/tests/test_optimising_test_suite.py +++ b/lib/testresources/tests/test_optimising_test_suite.py @@ -80,7 +80,7 @@ class TestOptimisingTestSuite(testtools.TestCase): return test_case def setUp(self): - testtools.TestCase.setUp(self) + super(TestOptimisingTestSuite, self).setUp() self.optimising_suite = testresources.OptimisingTestSuite() def testAddTest(self): @@ -333,7 +333,7 @@ class TestCostOfSwitching(testtools.TestCase): """Tests for cost_of_switching.""" def setUp(self): - testtools.TestCase.setUp(self) + super(TestCostOfSwitching, self).setUp() self.suite = testresources.OptimisingTestSuite() def makeResource(self, setUpCost=1, tearDownCost=1): @@ -420,7 +420,7 @@ class TestCostGraph(testtools.TestCase): class TestGraphStuff(testtools.TestCase): def setUp(self): - testtools.TestCase.setUp(self) + super(TestGraphStuff, self).setUp() class MockTest(unittest.TestCase): def __repr__(self): """The representation is the tests name. diff --git a/lib/testresources/tests/test_resourced_test_case.py b/lib/testresources/tests/test_resourced_test_case.py index eae40aa..7d2cfba 100644 --- a/lib/testresources/tests/test_resourced_test_case.py +++ b/lib/testresources/tests/test_resourced_test_case.py @@ -15,6 +15,7 @@ # license. # +import unittest import testtools import testresources from testresources.tests import ResultWithResourceExtensions @@ -44,7 +45,7 @@ class MockResourceInstance(object): class TestResourcedTestCase(testtools.TestCase): def setUp(self): - testtools.TestCase.setUp(self) + super(TestResourcedTestCase, self).setUp() class Example(testresources.ResourcedTestCase): def test_example(self): pass @@ -52,6 +53,33 @@ class TestResourcedTestCase(testtools.TestCase): self.resource = self.getUniqueString() self.resource_manager = MockResource(self.resource) + def testSetUpUsesSuper(self): + class OtherBaseCase(unittest.TestCase): + setUpCalled = False + def setUp(self): + self.setUpCalled = True + super(OtherBaseCase, self).setUp() + class OurCase(testresources.ResourcedTestCase, OtherBaseCase): + def runTest(self): + pass + ourCase = OurCase() + ourCase.setUp() + self.assertTrue(ourCase.setUpCalled) + + def testTearDownUsesSuper(self): + class OtherBaseCase(unittest.TestCase): + tearDownCalled = False + def tearDown(self): + self.tearDownCalled = True + super(OtherBaseCase, self).setUp() + class OurCase(testresources.ResourcedTestCase, OtherBaseCase): + def runTest(self): + pass + ourCase = OurCase() + ourCase.setUp() + ourCase.tearDown() + self.assertTrue(ourCase.tearDownCalled) + def testDefaults(self): self.assertEqual(self.resourced_case.resources, []) |