mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Improving help message for python -m unittest. Issue 8303.
This commit is contained in:
parent
638b869004
commit
72b1977221
2 changed files with 7 additions and 6 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
if sys.argv[0].endswith("__main__.py"):
|
if sys.argv[0].endswith("__main__.py"):
|
||||||
sys.argv[0] = "unittest"
|
sys.argv[0] = "python -m unittest"
|
||||||
|
|
||||||
__unittest = True
|
__unittest = True
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,8 @@ Options:
|
||||||
%(failfast)s%(catchbreak)s%(buffer)s
|
%(failfast)s%(catchbreak)s%(buffer)s
|
||||||
Examples:
|
Examples:
|
||||||
%(progName)s test_module - run tests from test_module
|
%(progName)s test_module - run tests from test_module
|
||||||
%(progName)s test_module.TestClass - run tests from
|
%(progName)s module.TestClass - run tests from module.TestClass
|
||||||
test_module.TestClass
|
%(progName)s module.Class.test_method - run specified test method
|
||||||
%(progName)s test_module.TestClass.test_method - run specified test method
|
|
||||||
|
|
||||||
[tests] can be a list of any number of test modules, classes and test
|
[tests] can be a list of any number of test modules, classes and test
|
||||||
methods.
|
methods.
|
||||||
|
@ -68,7 +67,7 @@ class TestProgram(object):
|
||||||
USAGE = USAGE_FROM_MODULE
|
USAGE = USAGE_FROM_MODULE
|
||||||
|
|
||||||
# defaults for testing
|
# defaults for testing
|
||||||
failfast = catchbreak = buffer = None
|
failfast = catchbreak = buffer = progName = None
|
||||||
|
|
||||||
def __init__(self, module='__main__', defaultTest=None, argv=None,
|
def __init__(self, module='__main__', defaultTest=None, argv=None,
|
||||||
testRunner=None, testLoader=loader.defaultTestLoader,
|
testRunner=None, testLoader=loader.defaultTestLoader,
|
||||||
|
@ -160,8 +159,10 @@ class TestProgram(object):
|
||||||
|
|
||||||
def _do_discovery(self, argv, Loader=loader.TestLoader):
|
def _do_discovery(self, argv, Loader=loader.TestLoader):
|
||||||
# handle command line args for test discovery
|
# handle command line args for test discovery
|
||||||
|
self.progName = '%s discover' % self.progName
|
||||||
import optparse
|
import optparse
|
||||||
parser = optparse.OptionParser()
|
parser = optparse.OptionParser()
|
||||||
|
parser.prog = self.progName
|
||||||
parser.add_option('-v', '--verbose', dest='verbose', default=False,
|
parser.add_option('-v', '--verbose', dest='verbose', default=False,
|
||||||
help='Verbose output', action='store_true')
|
help='Verbose output', action='store_true')
|
||||||
if self.failfast != False:
|
if self.failfast != False:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue