From eef159bd176ffeaae7cdc8450e3d6168fbfe4a59 Mon Sep 17 00:00:00 2001 From: Michael Foord Date: Mon, 22 Mar 2010 02:49:08 +0000 Subject: [PATCH] Correct usage message displayed for python -m unittest -h --- Lib/unittest/__init__.py | 3 +-- Lib/unittest/__main__.py | 3 ++- Lib/unittest/main.py | 8 +------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Lib/unittest/__init__.py b/Lib/unittest/__init__.py index 8f77127a0d2..7153802eb7f 100644 --- a/Lib/unittest/__init__.py +++ b/Lib/unittest/__init__.py @@ -52,6 +52,7 @@ __all__ = ['TestResult', 'TestCase', 'TestSuite', # Expose obsolete functions for backwards compatibility __all__.extend(['getTestCaseNames', 'makeSuite', 'findTestCases']) +__unittest = True from .result import TestResult from .case import (TestCase, FunctionTestCase, SkipTest, skip, skipIf, @@ -64,5 +65,3 @@ from .runner import TextTestRunner, TextTestResult # deprecated _TextTestResult = TextTestResult - -__unittest = True diff --git a/Lib/unittest/__main__.py b/Lib/unittest/__main__.py index 5023610c820..58e646d7859 100644 --- a/Lib/unittest/__main__.py +++ b/Lib/unittest/__main__.py @@ -6,6 +6,7 @@ if sys.argv[0].endswith("__main__.py"): __unittest = True +from .main import main, TestProgram, USAGE_AS_MAIN +TestProgram.USAGE = USAGE_AS_MAIN -from .main import main main(module=None) diff --git a/Lib/unittest/main.py b/Lib/unittest/main.py index 35466ccfabc..d0da7c070a7 100644 --- a/Lib/unittest/main.py +++ b/Lib/unittest/main.py @@ -58,17 +58,11 @@ Examples: in MyTestCase """ -if __name__ == '__main__': - USAGE = USAGE_AS_MAIN -else: - USAGE = USAGE_FROM_MODULE - - class TestProgram(object): """A command-line program that runs a set of tests; this is primarily for making test modules conveniently executable. """ - USAGE = USAGE + USAGE = USAGE_FROM_MODULE def __init__(self, module='__main__', defaultTest=None, argv=None, testRunner=None, testLoader=loader.defaultTestLoader, exit=True,