mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
Adds a verbosity keyword argument to unittest.main plus a minor fix allowing you to specify test modules / classes
from the command line. Closes issue 5995. Michael Foord
This commit is contained in:
parent
b1d45856c2
commit
5d31e057c5
4 changed files with 58 additions and 16 deletions
|
@ -3280,19 +3280,22 @@ class Test_TestProgram(TestCase):
|
|||
|
||||
runner = FakeRunner()
|
||||
|
||||
try:
|
||||
oldParseArgs = TestProgram.parseArgs
|
||||
TestProgram.parseArgs = lambda *args: None
|
||||
TestProgram.test = test
|
||||
|
||||
program = TestProgram(testRunner=runner, exit=False)
|
||||
|
||||
self.assertEqual(program.result, result)
|
||||
self.assertEqual(runner.test, test)
|
||||
|
||||
finally:
|
||||
oldParseArgs = TestProgram.parseArgs
|
||||
def restoreParseArgs():
|
||||
TestProgram.parseArgs = oldParseArgs
|
||||
TestProgram.parseArgs = lambda *args: None
|
||||
self.addCleanup(restoreParseArgs)
|
||||
|
||||
def removeTest():
|
||||
del TestProgram.test
|
||||
TestProgram.test = test
|
||||
self.addCleanup(removeTest)
|
||||
|
||||
program = TestProgram(testRunner=runner, exit=False, verbosity=2)
|
||||
|
||||
self.assertEqual(program.result, result)
|
||||
self.assertEqual(runner.test, test)
|
||||
self.assertEqual(program.verbosity, 2)
|
||||
|
||||
|
||||
class FooBar(unittest.TestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue