From 91dcd93bebcf974d12a300e6a8d0fc6eb9891884 Mon Sep 17 00:00:00 2001 From: Michael Foord Date: Tue, 14 Jul 2009 17:58:12 +0000 Subject: Move TestRunner initialisation into unittest.TestProgram.runTests. Fixes issue 6418. --- Lib/test/test_unittest.py | 9 --------- 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) -- cgit v0.12