]> granicus.if.org Git - python/commitdiff
Improving help message for python -m unittest. Issue 8303.
authorMichael Foord <fuzzyman@voidspace.org.uk>
Mon, 10 May 2010 20:21:16 +0000 (20:21 +0000)
committerMichael Foord <fuzzyman@voidspace.org.uk>
Mon, 10 May 2010 20:21:16 +0000 (20:21 +0000)
Lib/unittest/__main__.py
Lib/unittest/main.py

index 58e646d78590134ebeb0d1e5f500e9a7d29a8689..7320050ae954cc3037760f8470c91fbad7301280 100644 (file)
@@ -2,7 +2,7 @@
 
 import sys
 if sys.argv[0].endswith("__main__.py"):
-    sys.argv[0] = "unittest"
+    sys.argv[0] = "python -m unittest"
 
 __unittest = True
 
index 74d875cb1d4c769aa068740ec09c1956a60e58ab..3396bb0ab69caae8434116c696052050596cff3d 100644 (file)
@@ -22,10 +22,9 @@ Options:
   -q, --quiet      Minimal output
 %(failfast)s%(catchbreak)s%(buffer)s
 Examples:
-  %(progName)s test_module                       - run tests from test_module
-  %(progName)s test_module.TestClass             - run tests from
-                                                   test_module.TestClass
-  %(progName)s test_module.TestClass.test_method - run specified test method
+  %(progName)s test_module               - run tests from test_module
+  %(progName)s module.TestClass          - run tests from module.TestClass
+  %(progName)s module.Class.test_method  - run specified test method
 
 [tests] can be a list of any number of test modules, classes and test
 methods.
@@ -68,7 +67,7 @@ class TestProgram(object):
     USAGE = USAGE_FROM_MODULE
 
     # defaults for testing
-    failfast = catchbreak = buffer = None
+    failfast = catchbreak = buffer = progName = None
 
     def __init__(self, module='__main__', defaultTest=None, argv=None,
                     testRunner=None, testLoader=loader.defaultTestLoader,
@@ -160,8 +159,10 @@ class TestProgram(object):
 
     def _do_discovery(self, argv, Loader=loader.TestLoader):
         # handle command line args for test discovery
+        self.progName = '%s discover' % self.progName
         import optparse
         parser = optparse.OptionParser()
+        parser.prog = self.progName
         parser.add_option('-v', '--verbose', dest='verbose', default=False,
                           help='Verbose output', action='store_true')
         if self.failfast != False: