Index: Tools/2to3/test.py =================================================================== --- Tools/2to3/test.py (revision 61440) +++ Tools/2to3/test.py (working copy) @@ -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/" + print "test class : run tests in ." + 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)