mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Move initialising unittest.TestProgram.testRunner into runTests. Issue 6418.
This commit is contained in:
parent
f4a96e07d8
commit
bee87b4c1c
2 changed files with 5 additions and 12 deletions
|
@ -6,6 +6,7 @@ Still need testing:
|
||||||
TestCase.{assert,fail}* methods (some are tested implicitly)
|
TestCase.{assert,fail}* methods (some are tested implicitly)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
from test import test_support
|
from test import test_support
|
||||||
import unittest
|
import unittest
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
@ -2285,15 +2286,6 @@ class Test_Assertions(TestCase):
|
||||||
self.failIfAlmostEqual, 0, .1+.1j, places=0)
|
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
|
## Main
|
||||||
|
@ -2302,7 +2294,7 @@ class Test_TestProgram(TestCase):
|
||||||
def test_main():
|
def test_main():
|
||||||
test_support.run_unittest(Test_TestCase, Test_TestLoader,
|
test_support.run_unittest(Test_TestCase, Test_TestLoader,
|
||||||
Test_TestSuite, Test_TestResult, Test_FunctionTestCase,
|
Test_TestSuite, Test_TestResult, Test_FunctionTestCase,
|
||||||
Test_Assertions, Test_TestProgram)
|
Test_Assertions)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_main()
|
test_main()
|
||||||
|
|
|
@ -800,8 +800,6 @@ Examples:
|
||||||
def __init__(self, module='__main__', defaultTest=None,
|
def __init__(self, module='__main__', defaultTest=None,
|
||||||
argv=None, testRunner=None,
|
argv=None, testRunner=None,
|
||||||
testLoader=defaultTestLoader):
|
testLoader=defaultTestLoader):
|
||||||
if testRunner is None:
|
|
||||||
testRunner = TextTestRunner
|
|
||||||
if type(module) == type(''):
|
if type(module) == type(''):
|
||||||
self.module = __import__(module)
|
self.module = __import__(module)
|
||||||
for part in module.split('.')[1:]:
|
for part in module.split('.')[1:]:
|
||||||
|
@ -851,6 +849,9 @@ Examples:
|
||||||
self.module)
|
self.module)
|
||||||
|
|
||||||
def runTests(self):
|
def runTests(self):
|
||||||
|
if self.testRunner is None:
|
||||||
|
self.testRunner = TextTestRunner
|
||||||
|
|
||||||
if isinstance(self.testRunner, (type, types.ClassType)):
|
if isinstance(self.testRunner, (type, types.ClassType)):
|
||||||
try:
|
try:
|
||||||
testRunner = self.testRunner(verbosity=self.verbosity)
|
testRunner = self.testRunner(verbosity=self.verbosity)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue