summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Lange <jml@canonical.com>2008-10-29 20:29:17 +0000
committerJonathan Lange <jml@canonical.com>2008-10-29 20:29:17 +0000
commit9efb3dfa093ba8f1ab187ec3624aff5c76dda1fc (patch)
treec1cad589a6df6e83e28091991a2513792dc90661
parent9708919e2da7cd8f90166f18ba1fd950ba0e8026 (diff)
parent8e18b998ffc6beba75e7094ad599e52bce2e85f3 (diff)
downloadtestresources-9efb3dfa093ba8f1ab187ec3624aff5c76dda1fc.tar.gz
Merge pyunit3k rename
-rw-r--r--.bzrignore1
-rw-r--r--NEWS6
-rw-r--r--README6
-rw-r--r--lib/testresources/__init__.py13
-rw-r--r--lib/testresources/tests/test_optimising_test_suite.py16
-rw-r--r--lib/testresources/tests/test_resourced_test_case.py6
-rw-r--r--lib/testresources/tests/test_test_loader.py4
-rw-r--r--lib/testresources/tests/test_test_resource.py4
8 files changed, 35 insertions, 21 deletions
diff --git a/.bzrignore b/.bzrignore
index 5562ac3..9c0f2b7 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -1,3 +1,4 @@
TAGS
tags
lib/pyunit3k
+lib/testtools
diff --git a/NEWS b/NEWS
index 560b0fa..9ca0f49 100644
--- a/NEWS
+++ b/NEWS
@@ -8,8 +8,8 @@ IN DEVELOPMENT
CHANGES:
- * testresources needs pyunit3k to run the testresources test suite. You
- can still use testresources without using pyunit3k. (Jonathan Lange)
+ * testresources needs testtools to run the testresources test suite. You
+ can still use testresources without using testtools. (Jonathan Lange)
IMPROVEMENTS:
@@ -59,3 +59,5 @@ IN DEVELOPMENT
* OptimisingTestSuite has been refactored internally so that the way we
switch active resources and determine the cost of switching is more
obvious. (Jonathan Lange)
+
+ * Now imports from testtools rather than pyunit3k. (Jonathan Lange)
diff --git a/README b/README
index dbec241..be1edd2 100644
--- a/README
+++ b/README
@@ -27,10 +27,10 @@ Dependencies:
=============
* Python 2.4+
-* pyunit3k
+* testtools
-Note that pyunit3k is required for *running* the tests for testresources. You
-can use testresources in your own app without using pyunit3k.
+Note that testtools is required for *running* the tests for testresources. You
+can use testresources in your own app without using testtools.
How testresources works:
diff --git a/lib/testresources/__init__.py b/lib/testresources/__init__.py
index 5edbf17..1b6d41d 100644
--- a/lib/testresources/__init__.py
+++ b/lib/testresources/__init__.py
@@ -17,7 +17,6 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-from pyunit3k import iterate_tests
import unittest
@@ -26,6 +25,18 @@ def test_suite():
return testresources.tests.test_suite()
+def iterate_tests(test_suite_or_case):
+ """Iterate through all of the test cases in `test_suite_or_case`."""
+ try:
+ suite = iter(test_suite_or_case)
+ except TypeError:
+ yield test_suite_or_case
+ else:
+ for test in suite:
+ for subtest in iterate_tests(test):
+ yield subtest
+
+
def split_by_resources(tests):
"""Split a list of tests by whether or not they use test resources.
diff --git a/lib/testresources/tests/test_optimising_test_suite.py b/lib/testresources/tests/test_optimising_test_suite.py
index 79dc14e..842b689 100644
--- a/lib/testresources/tests/test_optimising_test_suite.py
+++ b/lib/testresources/tests/test_optimising_test_suite.py
@@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-import pyunit3k
+import testtools
import random
import testresources
from testresources import split_by_resources
@@ -48,7 +48,7 @@ class MakeCounter(testresources.TestResource):
return "boo"
-class TestOptimisingTestSuite(pyunit3k.TestCase):
+class TestOptimisingTestSuite(testtools.TestCase):
def makeTestCase(self):
"""Make a normal TestCase."""
@@ -64,7 +64,7 @@ class TestOptimisingTestSuite(pyunit3k.TestCase):
return test_case
def setUp(self):
- pyunit3k.TestCase.setUp(self)
+ testtools.TestCase.setUp(self)
self.optimising_suite = testresources.OptimisingTestSuite()
def testAdsorbTest(self):
@@ -142,7 +142,7 @@ class TestOptimisingTestSuite(pyunit3k.TestCase):
self.assertEqual(suite.sorted, True)
-class TestSplitByResources(pyunit3k.TestCase):
+class TestSplitByResources(testtools.TestCase):
"""Tests for split_by_resources."""
def makeTestCase(self):
@@ -188,11 +188,11 @@ class TestSplitByResources(pyunit3k.TestCase):
self.assertEqual(set(resourced_cases), set(haves))
-class TestCostOfSwitching(pyunit3k.TestCase):
+class TestCostOfSwitching(testtools.TestCase):
"""Tests for cost_of_switching."""
def setUp(self):
- pyunit3k.TestCase.setUp(self)
+ testtools.TestCase.setUp(self)
self.suite = testresources.OptimisingTestSuite()
def makeResource(self, setUpCost=1, tearDownCost=1):
@@ -241,7 +241,7 @@ class TestCostOfSwitching(pyunit3k.TestCase):
2, self.suite.cost_of_switching(set([a, c]), set([b, c])))
-class TestCostGraph(pyunit3k.TestCase):
+class TestCostGraph(testtools.TestCase):
"""Tests for calculating the cost graph of resourced test cases."""
def makeResource(self, setUpCost=1, tearDownCost=1):
@@ -280,7 +280,7 @@ class TestCostGraph(pyunit3k.TestCase):
set(a.resources), set(b.resources))}}, graph)
-class TestGraphStuff(pyunit3k.TestCase):
+class TestGraphStuff(testtools.TestCase):
def setUp(self):
diff --git a/lib/testresources/tests/test_resourced_test_case.py b/lib/testresources/tests/test_resourced_test_case.py
index f2966af..31b29fa 100644
--- a/lib/testresources/tests/test_resourced_test_case.py
+++ b/lib/testresources/tests/test_resourced_test_case.py
@@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-import pyunit3k
+import testtools
import testresources
@@ -39,10 +39,10 @@ class MockResource(testresources.TestResource):
return self._resource
-class TestResourcedTestCase(pyunit3k.TestCase):
+class TestResourcedTestCase(testtools.TestCase):
def setUp(self):
- pyunit3k.TestCase.setUp(self)
+ testtools.TestCase.setUp(self)
self.resourced_case = testresources.ResourcedTestCase('run')
self.resource = self.getUniqueString()
self.resource_manager = MockResource(self.resource)
diff --git a/lib/testresources/tests/test_test_loader.py b/lib/testresources/tests/test_test_loader.py
index a7983e1..f7f9385 100644
--- a/lib/testresources/tests/test_test_loader.py
+++ b/lib/testresources/tests/test_test_loader.py
@@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-import pyunit3k
+import testtools
from testresources import TestLoader, OptimisingTestSuite
from testresources.tests import TestUtil
@@ -29,7 +29,7 @@ def test_suite():
return result
-class TestTestLoader(pyunit3k.TestCase):
+class TestTestLoader(testtools.TestCase):
def testSuiteType(self):
# The testresources TestLoader loads tests into an
diff --git a/lib/testresources/tests/test_test_resource.py b/lib/testresources/tests/test_test_resource.py
index d822487..59f8729 100644
--- a/lib/testresources/tests/test_test_resource.py
+++ b/lib/testresources/tests/test_test_resource.py
@@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-import pyunit3k
+import testtools
import testresources
@@ -45,7 +45,7 @@ class MockResource(testresources.TestResource):
return "Boo!"
-class TestTestResource(pyunit3k.TestCase):
+class TestTestResource(testtools.TestCase):
def testUnimplementedGetResource(self):
# By default, TestResource raises NotImplementedError on getResource.