diff options
author | Michael Foord <fuzzyman@voidspace.org.uk> | 2009-07-14 17:58:12 (GMT) |
---|---|---|
committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2009-07-14 17:58:12 (GMT) |
commit | 91dcd93bebcf974d12a300e6a8d0fc6eb9891884 (patch) | |
tree | b1c6d94c75853c1af23b5ba5cde6e8fd1a51043e | |
parent | 78c06bd9b7f7eb31562177b6580bd6a80fe9a3ae (diff) | |
download | cpython-91dcd93bebcf974d12a300e6a8d0fc6eb9891884.zip cpython-91dcd93bebcf974d12a300e6a8d0fc6eb9891884.tar.gz cpython-91dcd93bebcf974d12a300e6a8d0fc6eb9891884.tar.bz2 |
Move TestRunner initialisation into unittest.TestProgram.runTests. Fixes issue 6418.
-rw-r--r-- | Lib/test/test_unittest.py | 9 | ||||
-rw-r--r-- | Lib/unittest.py | 4 |
2 files changed, 2 insertions, 11 deletions
diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py index 92a5fad..29f8975 100644 --- a/Lib/test/test_unittest.py +++ b/Lib/test/test_unittest.py @@ -3324,15 +3324,6 @@ class Test_TestProgram(TestCase): self.assertEqual(runner.test, test) self.assertEqual(program.verbosity, 2) - - def testTestProgram_testRunnerArgument(self): - program = object.__new__(TestProgram) - program.parseArgs = lambda _: None - program.runTests = lambda: None - program.__init__(testRunner=None) - self.assertEqual(program.testRunner, unittest.TextTestRunner) - - class FooBar(unittest.TestCase): def testPass(self): assert True diff --git a/Lib/unittest.py b/Lib/unittest.py index bf7baa1..064429c 100644 --- a/Lib/unittest.py +++ b/Lib/unittest.py @@ -1643,8 +1643,6 @@ class TestProgram(object): argv=None, testRunner=None, testLoader=defaultTestLoader, exit=True, verbosity=1): - if testRunner is None: - testRunner = TextTestRunner if isinstance(module, basestring): self.module = __import__(module) for part in module.split('.')[1:]: @@ -1734,6 +1732,8 @@ class TestProgram(object): self.test = loader.discover(start_dir, pattern, top_level_dir) def runTests(self): + if self.testRunner is None: + self.testRunner = TextTestRunner if isinstance(self.testRunner, (type, types.ClassType)): try: testRunner = self.testRunner(verbosity=self.verbosity) |