[Python-checkins] r61456 - sandbox/trunk/2to3/test.py
martin.v.loewis
python-checkins at python.org
Mon Mar 17 21:11:29 CET 2008
Author: martin.v.loewis
Date: Mon Mar 17 21:11:29 2008
New Revision: 61456
Modified:
sandbox/trunk/2to3/test.py
Log:
Patch #2364: Add command line options to test.py
Modified: sandbox/trunk/2to3/test.py
==============================================================================
--- sandbox/trunk/2to3/test.py (original)
+++ sandbox/trunk/2to3/test.py Mon Mar 17 21:11:29 2008
@@ -6,7 +6,33 @@
"""
# Author: Collin Winter
+import unittest
from lib2to3 import tests
import lib2to3.tests.support
+from sys import exit, argv
-tests.support.run_all_tests(tests=tests.all_tests)
+if '-h' in argv or '--help' in argv or len(argv) > 2:
+ print "Usage: %s [-h] [test suite[.test class]]" %(argv[0])
+ print "default : run all tests in lib2to3/tests/test_*.py"
+ print "test suite: run tests in lib2to3/tests/<test suite>"
+ print "test class : run tests in <test suite>.<test class>"
+ exit(1)
+
+if len(argv) == 2:
+ mod = tests
+ for m in argv[1].split("."):
+ mod = getattr(mod, m, None)
+ if not mod:
+ print "Error importing %s" %(m)
+ exit(1)
+
+ if argv[1].find(".") == -1:
+ # Just hte module was specified, load all the tests
+ suite = unittest.TestLoader().loadTestsFromModule(mod)
+ else:
+ # A class was specified, load that
+ suite = unittest.makeSuite(mod)
+else:
+ suite = tests.all_tests
+
+tests.support.run_all_tests(tests=suite)
More information about the Python-checkins
mailing list