[Python-checkins] CVS: python/dist/src/Lib/test regrtest.py,1.16,1.17
Skip Montanaro
python-dev@python.org
Fri, 30 Jun 2000 09:39:29 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory slayer.i.sourceforge.net:/tmp/cvs-serv843
Modified Files:
regrtest.py
Log Message:
* added a randomize flag and corresponding -r command line argument that
allows the caller to execute the various tests in pseudo-random order -
default is still to execute tests in the order returned by findtests().
* moved initialization of the various flag variables to the main() function
definition, making it possible to execute regrtest.main() interactively
and still override default behavior.
Index: regrtest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** regrtest.py 2000/05/05 14:27:39 1.16
--- regrtest.py 2000/06/30 16:39:27 1.17
***************
*** 14,17 ****
--- 14,18 ----
-x: exclude -- arguments are tests to *exclude*
-s: single -- run only a single test (see below)
+ -r: random -- randomize test execution order
If non-option arguments are present, they are names for tests to run,
***************
*** 34,41 ****
import getopt
import traceback
import test_support
! def main(tests=None, testdir=None):
"""Execute a test suite.
--- 35,44 ----
import getopt
import traceback
+ import random
import test_support
! def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
! exclude=0, single=0, randomize=0):
"""Execute a test suite.
***************
*** 53,70 ****
command-line will be used. If that's empty, too, then all *.py
files beginning with test_ will be used.
!
"""
try:
! opts, args = getopt.getopt(sys.argv[1:], 'vgqxs')
except getopt.error, msg:
print msg
print __doc__
return 2
- verbose = 0
- quiet = 0
- generate = 0
- exclude = 0
- single = 0
for o, a in opts:
if o == '-v': verbose = verbose+1
--- 56,72 ----
command-line will be used. If that's empty, too, then all *.py
files beginning with test_ will be used.
!
! The other six default arguments (verbose, quiet, generate, exclude,
! single, and randomize) allow programmers calling main() directly to
! set the values that would normally be set by flags on the command
! line.
"""
try:
! opts, args = getopt.getopt(sys.argv[1:], 'vgqxsr')
except getopt.error, msg:
print msg
print __doc__
return 2
for o, a in opts:
if o == '-v': verbose = verbose+1
***************
*** 73,76 ****
--- 75,79 ----
if o == '-x': exclude = 1
if o == '-s': single = 1
+ if o == '-r': randomize = 1
if generate and verbose:
print "-g and -v don't go together!"
***************
*** 105,108 ****
--- 108,113 ----
if single:
tests = tests[:1]
+ if randomize:
+ random.shuffle(tests)
test_support.verbose = verbose # Tell tests to be moderately quiet
save_modules = sys.modules.keys()