summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJonathan Lange <jml@canonical.com>2008-09-13 21:44:19 +1000
committerJonathan Lange <jml@canonical.com>2008-09-13 21:44:19 +1000
commit626ddc2cc539d3ac8f82e5112da69e18160836cb (patch)
treec033a364e7e2adb2aee2f11faed661aa0d4dd381 /lib
parent0862966fd9b971a8510232e8b648ffd9abdffdfc (diff)
downloadtestresources-626ddc2cc539d3ac8f82e5112da69e18160836cb.tar.gz
Add another test to satisfy my paranoia.
Diffstat (limited to 'lib')
-rw-r--r--lib/testresources/tests/test_optimising_test_suite.py31
1 files changed, 24 insertions, 7 deletions
diff --git a/lib/testresources/tests/test_optimising_test_suite.py b/lib/testresources/tests/test_optimising_test_suite.py
index aa3c86e..6ba7bd3 100644
--- a/lib/testresources/tests/test_optimising_test_suite.py
+++ b/lib/testresources/tests/test_optimising_test_suite.py
@@ -32,6 +32,16 @@ def test_suite():
return result
+class CustomSuite(unittest.TestSuite):
+ """Custom TestSuite that's comparable using == and !=."""
+
+ def __eq__(self, other):
+ return (self.__class__ == other.__class__
+ and self._tests == other._tests)
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
+
class MakeCounter(testresources.TestResource):
"""Test resource that counts makes and cleans."""
@@ -94,15 +104,9 @@ class TestOptimisingTestSuite(pyunit3k.TestCase):
self.optimising_suite.addTest(suite)
self.assertEqual([case1, case2, case3], self.optimising_suite._tests)
- def testAdsorbDistributesNonStandardSuiteStructure(self):
+ def testAddDistributesNonStandardSuiteStructure(self):
# addTest distributes all non-standard TestSuites across their
# members.
- class CustomSuite(unittest.TestSuite):
- def __eq__(self, other):
- return (self.__class__ == other.__class__
- and self._tests == other._tests)
- def __ne__(self, other):
- return not self.__eq__(other)
case1 = self.makeTestCase()
case2 = self.makeTestCase()
inner_suite = unittest.TestSuite([case2])
@@ -112,6 +116,19 @@ class TestOptimisingTestSuite(pyunit3k.TestCase):
[CustomSuite([case1]), CustomSuite([inner_suite])],
self.optimising_suite._tests)
+ def testAddPullsNonStandardSuitesUp(self):
+ # addTest flattens standard TestSuites, even those that contain custom
+ # suites. When it reaches the custom suites, it distributes them
+ # across their members.
+ case1 = self.makeTestCase()
+ case2 = self.makeTestCase()
+ inner_suite = CustomSuite([case1, case2])
+ self.optimising_suite.addTest(
+ unittest.TestSuite([unittest.TestSuite([inner_suite])]))
+ self.assertEqual(
+ [CustomSuite([case1]), CustomSuite([case2])],
+ self.optimising_suite._tests)
+
def testSingleCaseResourceAcquisition(self):
sample_resource = MakeCounter()
def getResourceCount():