[Python-checkins] cpython: Closes issue 16064. No longer hard code executable name in unittest help output.

michael.foord python-checkins at python.org
Fri Sep 28 16:14:52 CEST 2012


http://hg.python.org/cpython/rev/c76f1d78ff78
changeset:   79209:c76f1d78ff78
user:        Michael Foord <michael at voidspace.org.uk>
date:        Fri Sep 28 15:14:37 2012 +0100
summary:
  Closes issue 16064. No longer hard code executable name in unittest help output.

files:
  Lib/unittest/__main__.py |  9 ++++++++-
  Misc/NEWS                |  2 ++
  2 files changed, 10 insertions(+), 1 deletions(-)


diff --git a/Lib/unittest/__main__.py b/Lib/unittest/__main__.py
--- a/Lib/unittest/__main__.py
+++ b/Lib/unittest/__main__.py
@@ -2,7 +2,14 @@
 
 import sys
 if sys.argv[0].endswith("__main__.py"):
-    sys.argv[0] = "python -m unittest"
+    import os.path
+    # We change sys.argv[0] to make help message more useful
+    # use executable without path, unquoted
+    # (it's just a hint anyway)
+    # (if you have spaces in your executable you get what you deserve!)
+    executable = os.path.basename(sys.executable)
+    sys.argv[0] = executable + " -m unittest"
+    del os
 
 __unittest = True
 
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -36,6 +36,8 @@
 Library
 -------
 
+- Issue #16064: unittest -m claims executable is "python", not "python3"
+
 - Issue #15222: Insert blank line after each message in mbox mailboxes
 
 - Issue #16013: Fix CSV Reader parsing issue with ending quote characters.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list