88
99Command line options:
1010
11- -v: verbose -- print the name name of each test as it is being run
11+ -v: verbose -- run tests in verbose mode with output to stdout
1212-q: quiet -- don't print anything except if a test fails
1313-g: generate -- write the output file for a test instead of comparing it
1414-x: exclude -- arguments are tests to *exclude*
1717unless -x is given, in which case they are names for tests not to run.
1818If no test names are given, all tests are run.
1919
20- If -v is given *twice*, the tests themselves are run in verbose mode.
21- This is incompatible with -g and does not compare test output files.
20+ -v is incompatible with -g and does not compare test output files.
2221"""
2322
2423import sys
@@ -42,24 +41,28 @@ def main():
4241 exclude = 0
4342 for o , a in opts :
4443 if o == '-v' : verbose = verbose + 1
45- if o == '-q' : quiet = 1
44+ if o == '-q' : quiet = 1 ; verbose = 0
4645 if o == '-g' : generate = 1
4746 if o == '-x' : exclude = 1
48- if generate and verbose > 1 :
49- print "-g and more than one -v don't go together!"
47+ if generate and verbose :
48+ print "-g and -v don't go together!"
5049 return 2
5150 good = []
5251 bad = []
5352 skipped = []
53+ for i in range (len (args )):
54+ # Strip trailing ".py" from arguments
55+ if args [i ][- 3 :] == '.py' :
56+ args [i ] = args [i ][:- 3 ]
5457 if exclude :
5558 nottests [:0 ] = args
5659 args = []
5760 tests = args or findtests ()
58- test_support .verbose = verbose > 1 # Tell tests to be moderately quiet
61+ test_support .verbose = verbose # Tell tests to be moderately quiet
5962 for test in tests :
60- if verbose :
63+ if not quiet :
6164 print test
62- ok = runtest (test , generate , verbose > 1 )
65+ ok = runtest (test , generate , verbose )
6366 if ok > 0 :
6467 good .append (test )
6568 elif ok == 0 :
@@ -109,15 +112,15 @@ def findtests():
109112 tests .sort ()
110113 return stdtests + tests
111114
112- def runtest (test , generate , verbose2 ):
115+ def runtest (test , generate , verbose ):
113116 test_support .unload (test )
114117 testdir = findtestdir ()
115118 outputdir = os .path .join (testdir , "output" )
116119 outputfile = os .path .join (outputdir , test )
117120 try :
118121 if generate :
119122 cfp = open (outputfile , "w" )
120- elif verbose2 :
123+ elif verbose :
121124 cfp = sys .stdout
122125 else :
123126 cfp = Compare (outputfile )
@@ -140,7 +143,7 @@ def runtest(test, generate, verbose2):
140143 return 0
141144 except :
142145 print "test" , test , "crashed --" , sys .exc_type , ":" , sys .exc_value
143- if verbose2 :
146+ if verbose :
144147 traceback .print_exc (file = sys .stdout )
145148 return 0
146149 else :
0 commit comments