Improve support for discovery on testtools.tests.
authorRobert Collins <robertc@robertcollins.net>
Thu, 6 Nov 2014 13:47:32 +0000 (02:47 +1300)
committerRobert Collins <robertc@robertcollins.net>
Thu, 6 Nov 2014 13:47:32 +0000 (02:47 +1300)
Our tests currently import test_with_with into test_testcase so that
we could still run tests on python2.5. Since we no longer support
2.5, we don't need this hack. Its a hack because discovery will
import test_with_with directly itself, and thus we triggered
a duplicate test id error when attempting to use discover on the
testtools test base.

Change-Id: I027929ab4b0df350dd18ab01ffd5c493fe35e101

testtools/tests/__init__.py
testtools/tests/test_testcase.py
testtools/tests/test_with_with.py

index d40fcb35e380238ae35754ce5e7f1e27a9328abb..5e18e078221234f0a5ad716d051a727cd3888cdb 100644 (file)
@@ -25,6 +25,7 @@ def test_suite():
         test_testcase,
         test_testresult,
         test_testsuite,
+        test_with_with,
         )
     modules = [
         matchers,
@@ -44,6 +45,7 @@ def test_suite():
         test_testcase,
         test_testresult,
         test_testsuite,
+        test_with_with,
         ]
     suites = map(lambda x: x.test_suite(), modules)
     return TestSuite(suites)
index 4f3e14675a8e638767fb4e3619d44f7baf013ea4..eef96ed299e726e797a47fb08929fb1c5866a0b6 100644 (file)
@@ -51,12 +51,6 @@ from testtools.tests.helpers import (
     FullStackRunTest,
     LoggingResult,
     )
-try:
-    exec('from __future__ import with_statement')
-except SyntaxError:
-    pass
-else:
-    from testtools.tests.test_with_with import *
 
 
 class TestPlaceHolder(TestCase):
index 4305c624a86a7f82850f01f87a774770c9926baa..277b4d91c0cfc8304497d61c5b0467d947dd8152 100644 (file)
@@ -86,3 +86,8 @@ class TestExpectedException(TestCase):
                 pass
         exc = self.assertRaises(AssertionError, die)
         self.assertThat(exc.args[0], EndsWith(': foo'))
+
+
+def test_suite():
+    from unittest import TestLoader
+    return TestLoader().loadTestsFromName(__name__)