mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
Move TestRunner initialisation into unittest.TestProgram.runTests. Fixes issue 6418.
This commit is contained in:
parent
78c06bd9b7
commit
91dcd93beb
2 changed files with 2 additions and 11 deletions
|
@ -3324,15 +3324,6 @@ class Test_TestProgram(TestCase):
|
||||||
self.assertEqual(runner.test, test)
|
self.assertEqual(runner.test, test)
|
||||||
self.assertEqual(program.verbosity, 2)
|
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):
|
class FooBar(unittest.TestCase):
|
||||||
def testPass(self):
|
def testPass(self):
|
||||||
assert True
|
assert True
|
||||||
|
|
|
@ -1643,8 +1643,6 @@ class TestProgram(object):
|
||||||
argv=None, testRunner=None,
|
argv=None, testRunner=None,
|
||||||
testLoader=defaultTestLoader, exit=True,
|
testLoader=defaultTestLoader, exit=True,
|
||||||
verbosity=1):
|
verbosity=1):
|
||||||
if testRunner is None:
|
|
||||||
testRunner = TextTestRunner
|
|
||||||
if isinstance(module, basestring):
|
if isinstance(module, basestring):
|
||||||
self.module = __import__(module)
|
self.module = __import__(module)
|
||||||
for part in module.split('.')[1:]:
|
for part in module.split('.')[1:]:
|
||||||
|
@ -1734,6 +1732,8 @@ class TestProgram(object):
|
||||||
self.test = loader.discover(start_dir, pattern, top_level_dir)
|
self.test = loader.discover(start_dir, pattern, top_level_dir)
|
||||||
|
|
||||||
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