Restore default testRunner argument in unittest.main to None. Issue 6177.

This commit is contained in:
Michael Foord 2009-06-02 18:22:38 +00:00
parent 05f26d88fd
commit 48bc8203cc
2 changed files with 15 additions and 2 deletions

View File

@ -2284,6 +2284,17 @@ class Test_Assertions(TestCase):
self.assertRaises(AssertionError,
self.failIfAlmostEqual, 0, .1+.1j, places=0)
class Test_TestProgram(TestCase):
def testTestProgram_testRunnerArgument(self):
program = object.__new__(unittest.TestProgram)
program.parseArgs = lambda _: None
program.runTests = lambda: None
program.__init__(testRunner=None)
self.assertEqual(program.testRunner, unittest.TextTestRunner)
######################################################################
## Main
######################################################################
@ -2291,7 +2302,7 @@ class Test_Assertions(TestCase):
def test_main():
test_support.run_unittest(Test_TestCase, Test_TestLoader,
Test_TestSuite, Test_TestResult, Test_FunctionTestCase,
Test_Assertions)
Test_Assertions, Test_TestProgram)
if __name__ == "__main__":
test_main()

View File

@ -798,8 +798,10 @@ Examples:
in MyTestCase
"""
def __init__(self, module='__main__', defaultTest=None,
argv=None, testRunner=TextTestRunner,
argv=None, testRunner=None,
testLoader=defaultTestLoader):
if testRunner is None:
testRunner = TextTestRunner
if type(module) == type(''):
self.module = __import__(module)
for part in module.split('.')[1:]: