PyXR

c:\python24\lib \ test \ regrtest.py



0001 #! /usr/bin/env python
0002 
0003 """Regression test.
0004 
0005 This will find all modules whose name is "test_*" in the test
0006 directory, and run them.  Various command line options provide
0007 additional facilities.
0008 
0009 Command line options:
0010 
0011 -v: verbose    -- run tests in verbose mode with output to stdout
0012 -q: quiet      -- don't print anything except if a test fails
0013 -g: generate   -- write the output file for a test instead of comparing it
0014 -x: exclude    -- arguments are tests to *exclude*
0015 -s: single     -- run only a single test (see below)
0016 -r: random     -- randomize test execution order
0017 -f: fromfile   -- read names of tests to run from a file (see below)
0018 -l: findleaks  -- if GC is available detect tests that leak memory
0019 -u: use        -- specify which special resource intensive tests to run
0020 -h: help       -- print this text and exit
0021 -t: threshold  -- call gc.set_threshold(N)
0022 -T: coverage   -- turn on code coverage using the trace module
0023 -L: runleaks   -- run the leaks(1) command just before exit
0024 -R: huntrleaks -- search for reference leaks (needs debug build, v. slow)
0025 
0026 If non-option arguments are present, they are names for tests to run,
0027 unless -x is given, in which case they are names for tests not to run.
0028 If no test names are given, all tests are run.
0029 
0030 -v is incompatible with -g and does not compare test output files.
0031 
0032 -T turns on code coverage tracing with the trace module.
0033 
0034 -s means to run only a single test and exit.  This is useful when
0035 doing memory analysis on the Python interpreter (which tend to consume
0036 too many resources to run the full regression test non-stop).  The
0037 file /tmp/pynexttest is read to find the next test to run.  If this
0038 file is missing, the first test_*.py file in testdir or on the command
0039 line is used.  (actually tempfile.gettempdir() is used instead of
0040 /tmp).
0041 
0042 -f reads the names of tests from the file given as f's argument, one
0043 or more test names per line.  Whitespace is ignored.  Blank lines and
0044 lines beginning with '#' are ignored.  This is especially useful for
0045 whittling down failures involving interactions among tests.
0046 
0047 -L causes the leaks(1) command to be run just before exit if it exists.
0048 leaks(1) is available on Mac OS X and presumably on some other
0049 FreeBSD-derived systems.
0050 
0051 -R runs each test several times and examines sys.gettotalrefcount() to
0052 see if the test appears to be leaking references.  The argument should
0053 be of the form stab:run:fname where 'stab' is the number of times the
0054 test is run to let gettotalrefcount settle down, 'run' is the number
0055 of times further it is run and 'fname' is the name of the file the
0056 reports are written to.  These parameters all have defaults (5, 4 and
0057 "reflog.txt" respectively), so the minimal invocation is '-R ::'.
0058 
0059 -u is used to specify which special resource intensive tests to run,
0060 such as those requiring large file support or network connectivity.
0061 The argument is a comma-separated list of words indicating the
0062 resources to test.  Currently only the following are defined:
0063 
0064     all -       Enable all special resources.
0065 
0066     audio -     Tests that use the audio device.  (There are known
0067                 cases of broken audio drivers that can crash Python or
0068                 even the Linux kernel.)
0069 
0070     curses -    Tests that use curses and will modify the terminal's
0071                 state and output modes.
0072 
0073     largefile - It is okay to run some test that may create huge
0074                 files.  These tests can take a long time and may
0075                 consume >2GB of disk space temporarily.
0076 
0077     network -   It is okay to run tests that use external network
0078                 resource, e.g. testing SSL support for sockets.
0079 
0080     bsddb -     It is okay to run the bsddb testsuite, which takes
0081                 a long time to complete.
0082 
0083     decimal -   Test the decimal module against a large suite that
0084                 verifies compliance with standards.
0085 
0086     compiler -  Test the compiler package by compiling all the source
0087                 in the standard library and test suite.  This takes
0088                 a long time.
0089 
0090 To enable all resources except one, use '-uall,-<resource>'.  For
0091 example, to run all the tests except for the bsddb tests, give the
0092 option '-uall,-bsddb'.
0093 """
0094 
0095 import os
0096 import sys
0097 import getopt
0098 import random
0099 import warnings
0100 import sre
0101 import cStringIO
0102 import traceback
0103 
0104 # I see no other way to suppress these warnings;
0105 # putting them in test_grammar.py has no effect:
0106 warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning,
0107                         ".*test.test_grammar$")
0108 if sys.maxint > 0x7fffffff:
0109     # Also suppress them in <string>, because for 64-bit platforms,
0110     # that's where test_grammar.py hides them.
0111     warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning,
0112                             "<string>")
0113 
0114 # MacOSX (a.k.a. Darwin) has a default stack size that is too small
0115 # for deeply recursive regular expressions.  We see this as crashes in
0116 # the Python test suite when running test_re.py and test_sre.py.  The
0117 # fix is to set the stack limit to 2048.
0118 # This approach may also be useful for other Unixy platforms that
0119 # suffer from small default stack limits.
0120 if sys.platform == 'darwin':
0121     try:
0122         import resource
0123     except ImportError:
0124         pass
0125     else:
0126         soft, hard = resource.getrlimit(resource.RLIMIT_STACK)
0127         newsoft = min(hard, max(soft, 1024*2048))
0128         resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard))
0129 
0130 from test import test_support
0131 
0132 RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb',
0133                   'decimal', 'compiler')
0134 
0135 
0136 def usage(code, msg=''):
0137     print __doc__
0138     if msg: print msg
0139     sys.exit(code)
0140 
0141 
0142 def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
0143          exclude=False, single=False, randomize=False, fromfile=None,
0144          findleaks=False, use_resources=None, trace=False, runleaks=False,
0145          huntrleaks=False):
0146     """Execute a test suite.
0147 
0148     This also parses command-line options and modifies its behavior
0149     accordingly.
0150 
0151     tests -- a list of strings containing test names (optional)
0152     testdir -- the directory in which to look for tests (optional)
0153 
0154     Users other than the Python test suite will certainly want to
0155     specify testdir; if it's omitted, the directory containing the
0156     Python test suite is searched for.
0157 
0158     If the tests argument is omitted, the tests listed on the
0159     command-line will be used.  If that's empty, too, then all *.py
0160     files beginning with test_ will be used.
0161 
0162     The other default arguments (verbose, quiet, generate, exclude, single,
0163     randomize, findleaks, use_resources, and trace) allow programmers calling
0164     main() directly to set the values that would normally be set by flags on
0165     the command line.
0166     """
0167 
0168     test_support.record_original_stdout(sys.stdout)
0169     try:
0170         opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:TLR:',
0171                                    ['help', 'verbose', 'quiet', 'generate',
0172                                     'exclude', 'single', 'random', 'fromfile',
0173                                     'findleaks', 'use=', 'threshold=', 'trace',
0174                                     'runleaks', 'huntrleaks='
0175                                     ])
0176     except getopt.error, msg:
0177         usage(2, msg)
0178 
0179     # Defaults
0180     if use_resources is None:
0181         use_resources = []
0182     for o, a in opts:
0183         if o in ('-h', '--help'):
0184             usage(0)
0185         elif o in ('-v', '--verbose'):
0186             verbose += 1
0187         elif o in ('-q', '--quiet'):
0188             quiet = True;
0189             verbose = 0
0190         elif o in ('-g', '--generate'):
0191             generate = True
0192         elif o in ('-x', '--exclude'):
0193             exclude = True
0194         elif o in ('-s', '--single'):
0195             single = True
0196         elif o in ('-r', '--randomize'):
0197             randomize = True
0198         elif o in ('-f', '--fromfile'):
0199             fromfile = a
0200         elif o in ('-l', '--findleaks'):
0201             findleaks = True
0202         elif o in ('-L', '--runleaks'):
0203             runleaks = True
0204         elif o in ('-t', '--threshold'):
0205             import gc
0206             gc.set_threshold(int(a))
0207         elif o in ('-T', '--coverage'):
0208             trace = True
0209         elif o in ('-R', '--huntrleaks'):
0210             huntrleaks = a.split(':')
0211             if len(huntrleaks) != 3:
0212                 print a, huntrleaks
0213                 usage(2, '-R takes three colon-separated arguments')
0214             if len(huntrleaks[0]) == 0:
0215                 huntrleaks[0] = 5
0216             else:
0217                 huntrleaks[0] = int(huntrleaks[0])
0218             if len(huntrleaks[1]) == 0:
0219                 huntrleaks[1] = 4
0220             else:
0221                 huntrleaks[1] = int(huntrleaks[1])
0222             if len(huntrleaks[2]) == 0:
0223                 huntrleaks[2] = "reflog.txt"
0224         elif o in ('-u', '--use'):
0225             u = [x.lower() for x in a.split(',')]
0226             for r in u:
0227                 if r == 'all':
0228                     use_resources[:] = RESOURCE_NAMES
0229                     continue
0230                 remove = False
0231                 if r[0] == '-':
0232                     remove = True
0233                     r = r[1:]
0234                 if r not in RESOURCE_NAMES:
0235                     usage(1, 'Invalid -u/--use option: ' + a)
0236                 if remove:
0237                     if r in use_resources:
0238                         use_resources.remove(r)
0239                 elif r not in use_resources:
0240                     use_resources.append(r)
0241     if generate and verbose:
0242         usage(2, "-g and -v don't go together!")
0243     if single and fromfile:
0244         usage(2, "-s and -f don't go together!")
0245 
0246     good = []
0247     bad = []
0248     skipped = []
0249     resource_denieds = []
0250 
0251     if findleaks:
0252         try:
0253             import gc
0254         except ImportError:
0255             print 'No GC available, disabling findleaks.'
0256             findleaks = False
0257         else:
0258             # Uncomment the line below to report garbage that is not
0259             # freeable by reference counting alone.  By default only
0260             # garbage that is not collectable by the GC is reported.
0261             #gc.set_debug(gc.DEBUG_SAVEALL)
0262             found_garbage = []
0263 
0264     if single:
0265         from tempfile import gettempdir
0266         filename = os.path.join(gettempdir(), 'pynexttest')
0267         try:
0268             fp = open(filename, 'r')
0269             next = fp.read().strip()
0270             tests = [next]
0271             fp.close()
0272         except IOError:
0273             pass
0274 
0275     if fromfile:
0276         tests = []
0277         fp = open(fromfile)
0278         for line in fp:
0279             guts = line.split() # assuming no test has whitespace in its name
0280             if guts and not guts[0].startswith('#'):
0281                 tests.extend(guts)
0282         fp.close()
0283 
0284     # Strip .py extensions.
0285     if args:
0286         args = map(removepy, args)
0287     if tests:
0288         tests = map(removepy, tests)
0289 
0290     stdtests = STDTESTS[:]
0291     nottests = NOTTESTS[:]
0292     if exclude:
0293         for arg in args:
0294             if arg in stdtests:
0295                 stdtests.remove(arg)
0296         nottests[:0] = args
0297         args = []
0298     tests = tests or args or findtests(testdir, stdtests, nottests)
0299     if single:
0300         tests = tests[:1]
0301     if randomize:
0302         random.shuffle(tests)
0303     if trace:
0304         import trace
0305         tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix],
0306                              trace=False, count=True)
0307         coverdir = os.path.join(os.getcwd(), 'coverage')
0308     test_support.verbose = verbose      # Tell tests to be moderately quiet
0309     test_support.use_resources = use_resources
0310     save_modules = sys.modules.keys()
0311     for test in tests:
0312         if not quiet:
0313             print test
0314             sys.stdout.flush()
0315         if trace:
0316             # If we're tracing code coverage, then we don't exit with status
0317             # if on a false return value from main.
0318             tracer.runctx('runtest(test, generate, verbose, quiet, testdir)',
0319                           globals=globals(), locals=vars())
0320         else:
0321             ok = runtest(test, generate, verbose, quiet, testdir, huntrleaks)
0322             if ok > 0:
0323                 good.append(test)
0324             elif ok == 0:
0325                 bad.append(test)
0326             else:
0327                 skipped.append(test)
0328                 if ok == -2:
0329                     resource_denieds.append(test)
0330         if findleaks:
0331             gc.collect()
0332             if gc.garbage:
0333                 print "Warning: test created", len(gc.garbage),
0334                 print "uncollectable object(s)."
0335                 # move the uncollectable objects somewhere so we don't see
0336                 # them again
0337                 found_garbage.extend(gc.garbage)
0338                 del gc.garbage[:]
0339         # Unload the newly imported modules (best effort finalization)
0340         for module in sys.modules.keys():
0341             if module not in save_modules and module.startswith("test."):
0342                 test_support.unload(module)
0343 
0344     # The lists won't be sorted if running with -r
0345     good.sort()
0346     bad.sort()
0347     skipped.sort()
0348 
0349     if good and not quiet:
0350         if not bad and not skipped and len(good) > 1:
0351             print "All",
0352         print count(len(good), "test"), "OK."
0353         if verbose:
0354             print "CAUTION:  stdout isn't compared in verbose mode:"
0355             print "a test that passes in verbose mode may fail without it."
0356     if bad:
0357         print count(len(bad), "test"), "failed:"
0358         printlist(bad)
0359     if skipped and not quiet:
0360         print count(len(skipped), "test"), "skipped:"
0361         printlist(skipped)
0362 
0363         e = _ExpectedSkips()
0364         plat = sys.platform
0365         if e.isvalid():
0366             surprise = set(skipped) - e.getexpected() - set(resource_denieds)
0367             if surprise:
0368                 print count(len(surprise), "skip"), \
0369                       "unexpected on", plat + ":"
0370                 printlist(surprise)
0371             else:
0372                 print "Those skips are all expected on", plat + "."
0373         else:
0374             print "Ask someone to teach regrtest.py about which tests are"
0375             print "expected to get skipped on", plat + "."
0376 
0377     if single:
0378         alltests = findtests(testdir, stdtests, nottests)
0379         for i in range(len(alltests)):
0380             if tests[0] == alltests[i]:
0381                 if i == len(alltests) - 1:
0382                     os.unlink(filename)
0383                 else:
0384                     fp = open(filename, 'w')
0385                     fp.write(alltests[i+1] + '\n')
0386                     fp.close()
0387                 break
0388         else:
0389             os.unlink(filename)
0390 
0391     if trace:
0392         r = tracer.results()
0393         r.write_results(show_missing=True, summary=True, coverdir=coverdir)
0394 
0395     if runleaks:
0396         os.system("leaks %d" % os.getpid())
0397 
0398     sys.exit(len(bad) > 0)
0399 
0400 
0401 STDTESTS = [
0402     'test_grammar',
0403     'test_opcodes',
0404     'test_operations',
0405     'test_builtin',
0406     'test_exceptions',
0407     'test_types',
0408    ]
0409 
0410 NOTTESTS = [
0411     'test_support',
0412     'test_future1',
0413     'test_future2',
0414     'test_future3',
0415     ]
0416 
0417 def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
0418     """Return a list of all applicable test modules."""
0419     if not testdir: testdir = findtestdir()
0420     names = os.listdir(testdir)
0421     tests = []
0422     for name in names:
0423         if name[:5] == "test_" and name[-3:] == os.extsep+"py":
0424             modname = name[:-3]
0425             if modname not in stdtests and modname not in nottests:
0426                 tests.append(modname)
0427     tests.sort()
0428     return stdtests + tests
0429 
0430 def runtest(test, generate, verbose, quiet, testdir=None, huntrleaks=False):
0431     """Run a single test.
0432     test -- the name of the test
0433     generate -- if true, generate output, instead of running the test
0434     and comparing it to a previously created output file
0435     verbose -- if true, print more messages
0436     quiet -- if true, don't print 'skipped' messages (probably redundant)
0437     testdir -- test directory
0438     """
0439     test_support.unload(test)
0440     if not testdir:
0441         testdir = findtestdir()
0442     outputdir = os.path.join(testdir, "output")
0443     outputfile = os.path.join(outputdir, test)
0444     if verbose:
0445         cfp = None
0446     else:
0447         cfp = cStringIO.StringIO()
0448     if huntrleaks:
0449         refrep = open(huntrleaks[2], "a")
0450     try:
0451         save_stdout = sys.stdout
0452         try:
0453             if cfp:
0454                 sys.stdout = cfp
0455                 print test              # Output file starts with test name
0456             if test.startswith('test.'):
0457                 abstest = test
0458             else:
0459                 # Always import it from the test package
0460                 abstest = 'test.' + test
0461             the_package = __import__(abstest, globals(), locals(), [])
0462             the_module = getattr(the_package, test)
0463             # Most tests run to completion simply as a side-effect of
0464             # being imported.  For the benefit of tests that can't run
0465             # that way (like test_threaded_import), explicitly invoke
0466             # their test_main() function (if it exists).
0467             indirect_test = getattr(the_module, "test_main", None)
0468             if indirect_test is not None:
0469                 indirect_test()
0470             if huntrleaks:
0471                 # This code *is* hackish and inelegant, yes.
0472                 # But it seems to do the job.
0473                 import copy_reg
0474                 fs = warnings.filters[:]
0475                 ps = copy_reg.dispatch_table.copy()
0476                 pic = sys.path_importer_cache.copy()
0477                 import gc
0478                 def cleanup():
0479                     import _strptime, urlparse, warnings, dircache
0480                     from distutils.dir_util import _path_created
0481                     _path_created.clear()
0482                     warnings.filters[:] = fs
0483                     gc.collect()
0484                     sre.purge()
0485                     _strptime._regex_cache.clear()
0486                     urlparse.clear_cache()
0487                     copy_reg.dispatch_table.clear()
0488                     copy_reg.dispatch_table.update(ps)
0489                     sys.path_importer_cache.clear()
0490                     sys.path_importer_cache.update(pic)
0491                     dircache.reset()
0492                 if indirect_test:
0493                     def run_the_test():
0494                         indirect_test()
0495                 else:
0496                     def run_the_test():
0497                         reload(the_module)
0498                 deltas = []
0499                 repcount = huntrleaks[0] + huntrleaks[1]
0500                 print >> sys.stderr, "beginning", repcount, "repetitions"
0501                 print >> sys.stderr, \
0502                       ("1234567890"*(repcount//10 + 1))[:repcount]
0503                 for i in range(repcount):
0504                     rc = sys.gettotalrefcount()
0505                     run_the_test()
0506                     sys.stderr.write('.')
0507                     cleanup()
0508                     deltas.append(sys.gettotalrefcount() - rc - 2)
0509                 print >>sys.stderr
0510                 if max(map(abs, deltas[-huntrleaks[1]:])) > 0:
0511                     print >>sys.stderr, test, 'leaked', \
0512                           deltas[-huntrleaks[1]:], 'references'
0513                     print >>refrep, test, 'leaked', \
0514                           deltas[-huntrleaks[1]:], 'references'
0515                 # The end of the huntrleaks hackishness.
0516         finally:
0517             sys.stdout = save_stdout
0518     except test_support.ResourceDenied, msg:
0519         if not quiet:
0520             print test, "skipped --", msg
0521             sys.stdout.flush()
0522         return -2
0523     except (ImportError, test_support.TestSkipped), msg:
0524         if not quiet:
0525             print test, "skipped --", msg
0526             sys.stdout.flush()
0527         return -1
0528     except KeyboardInterrupt:
0529         raise
0530     except test_support.TestFailed, msg:
0531         print "test", test, "failed --", msg
0532         sys.stdout.flush()
0533         return 0
0534     except:
0535         type, value = sys.exc_info()[:2]
0536         print "test", test, "crashed --", str(type) + ":", value
0537         sys.stdout.flush()
0538         if verbose:
0539             traceback.print_exc(file=sys.stdout)
0540             sys.stdout.flush()
0541         return 0
0542     else:
0543         if not cfp:
0544             return 1
0545         output = cfp.getvalue()
0546         if generate:
0547             if output == test + "\n":
0548                 if os.path.exists(outputfile):
0549                     # Write it since it already exists (and the contents
0550                     # may have changed), but let the user know it isn't
0551                     # needed:
0552                     print "output file", outputfile, \
0553                           "is no longer needed; consider removing it"
0554                 else:
0555                     # We don't need it, so don't create it.
0556                     return 1
0557             fp = open(outputfile, "w")
0558             fp.write(output)
0559             fp.close()
0560             return 1
0561         if os.path.exists(outputfile):
0562             fp = open(outputfile, "r")
0563             expected = fp.read()
0564             fp.close()
0565         else:
0566             expected = test + "\n"
0567         if output == expected or huntrleaks:
0568             return 1
0569         print "test", test, "produced unexpected output:"
0570         sys.stdout.flush()
0571         reportdiff(expected, output)
0572         sys.stdout.flush()
0573         return 0
0574 
0575 def reportdiff(expected, output):
0576     import difflib
0577     print "*" * 70
0578     a = expected.splitlines(1)
0579     b = output.splitlines(1)
0580     sm = difflib.SequenceMatcher(a=a, b=b)
0581     tuples = sm.get_opcodes()
0582 
0583     def pair(x0, x1):
0584         # x0:x1 are 0-based slice indices; convert to 1-based line indices.
0585         x0 += 1
0586         if x0 >= x1:
0587             return "line " + str(x0)
0588         else:
0589             return "lines %d-%d" % (x0, x1)
0590 
0591     for op, a0, a1, b0, b1 in tuples:
0592         if op == 'equal':
0593             pass
0594 
0595         elif op == 'delete':
0596             print "***", pair(a0, a1), "of expected output missing:"
0597             for line in a[a0:a1]:
0598                 print "-", line,
0599 
0600         elif op == 'replace':
0601             print "*** mismatch between", pair(a0, a1), "of expected", \
0602                   "output and", pair(b0, b1), "of actual output:"
0603             for line in difflib.ndiff(a[a0:a1], b[b0:b1]):
0604                 print line,
0605 
0606         elif op == 'insert':
0607             print "***", pair(b0, b1), "of actual output doesn't appear", \
0608                   "in expected output after line", str(a1)+":"
0609             for line in b[b0:b1]:
0610                 print "+", line,
0611 
0612         else:
0613             print "get_opcodes() returned bad tuple?!?!", (op, a0, a1, b0, b1)
0614 
0615     print "*" * 70
0616 
0617 def findtestdir():
0618     if __name__ == '__main__':
0619         file = sys.argv[0]
0620     else:
0621         file = __file__
0622     testdir = os.path.dirname(file) or os.curdir
0623     return testdir
0624 
0625 def removepy(name):
0626     if name.endswith(os.extsep + "py"):
0627         name = name[:-3]
0628     return name
0629 
0630 def count(n, word):
0631     if n == 1:
0632         return "%d %s" % (n, word)
0633     else:
0634         return "%d %ss" % (n, word)
0635 
0636 def printlist(x, width=70, indent=4):
0637     """Print the elements of iterable x to stdout.
0638 
0639     Optional arg width (default 70) is the maximum line length.
0640     Optional arg indent (default 4) is the number of blanks with which to
0641     begin each line.
0642     """
0643 
0644     from textwrap import fill
0645     blanks = ' ' * indent
0646     print fill(' '.join(map(str, x)), width,
0647                initial_indent=blanks, subsequent_indent=blanks)
0648 
0649 # Map sys.platform to a string containing the basenames of tests
0650 # expected to be skipped on that platform.
0651 #
0652 # Special cases:
0653 #     test_pep277
0654 #         The _ExpectedSkips constructor adds this to the set of expected
0655 #         skips if not os.path.supports_unicode_filenames.
0656 #     test_normalization
0657 #         Whether a skip is expected here depends on whether a large test
0658 #         input file has been downloaded.  test_normalization.skip_expected
0659 #         controls that.
0660 #     test_socket_ssl
0661 #         Controlled by test_socket_ssl.skip_expected.  Requires the network
0662 #         resource, and a socket module with ssl support.
0663 #     test_timeout
0664 #         Controlled by test_timeout.skip_expected.  Requires the network
0665 #         resource and a socket module.
0666 #     test_codecmaps_*
0667 #         Whether a skip is expected here depends on whether a large test
0668 #         input file has been downloaded.  test_codecmaps_*.skip_expected
0669 #         controls that.
0670 
0671 _expectations = {
0672     'win32':
0673         """
0674         test__locale
0675         test_applesingle
0676         test_al
0677         test_bsddb185
0678         test_bsddb3
0679         test_cd
0680         test_cl
0681         test_commands
0682         test_crypt
0683         test_curses
0684         test_dbm
0685         test_dl
0686         test_fcntl
0687         test_fork1
0688         test_gdbm
0689         test_gl
0690         test_grp
0691         test_imgfile
0692         test_ioctl
0693         test_largefile
0694         test_linuxaudiodev
0695         test_mhlib
0696         test_nis
0697         test_openpty
0698         test_ossaudiodev
0699         test_poll
0700         test_posix
0701         test_pty
0702         test_pwd
0703         test_resource
0704         test_signal
0705         test_sunaudiodev
0706         test_threadsignals
0707         test_timing
0708         """,
0709     'linux2':
0710         """
0711         test_al
0712         test_applesingle
0713         test_bsddb185
0714         test_cd
0715         test_cl
0716         test_curses
0717         test_dl
0718         test_gl
0719         test_imgfile
0720         test_largefile
0721         test_linuxaudiodev
0722         test_nis
0723         test_ntpath
0724         test_ossaudiodev
0725         test_sunaudiodev
0726         """,
0727    'mac':
0728         """
0729         test_al
0730         test_atexit
0731         test_bsddb
0732         test_bsddb185
0733         test_bsddb3
0734         test_bz2
0735         test_cd
0736         test_cl
0737         test_commands
0738         test_crypt
0739         test_curses
0740         test_dbm
0741         test_dl
0742         test_fcntl
0743         test_fork1
0744         test_gl
0745         test_grp
0746         test_ioctl
0747         test_imgfile
0748         test_largefile
0749         test_linuxaudiodev
0750         test_locale
0751         test_mmap
0752         test_nis
0753         test_ntpath
0754         test_openpty
0755         test_ossaudiodev
0756         test_poll
0757         test_popen
0758         test_popen2
0759         test_posix
0760         test_pty
0761         test_pwd
0762         test_resource
0763         test_signal
0764         test_sunaudiodev
0765         test_sundry
0766         test_tarfile
0767         test_timing
0768         """,
0769     'unixware7':
0770         """
0771         test_al
0772         test_applesingle
0773         test_bsddb
0774         test_bsddb185
0775         test_cd
0776         test_cl
0777         test_dl
0778         test_gl
0779         test_imgfile
0780         test_largefile
0781         test_linuxaudiodev
0782         test_minidom
0783         test_nis
0784         test_ntpath
0785         test_openpty
0786         test_pyexpat
0787         test_sax
0788         test_sunaudiodev
0789         test_sundry
0790         """,
0791     'openunix8':
0792         """
0793         test_al
0794         test_applesingle
0795         test_bsddb
0796         test_bsddb185
0797         test_cd
0798         test_cl
0799         test_dl
0800         test_gl
0801         test_imgfile
0802         test_largefile
0803         test_linuxaudiodev
0804         test_minidom
0805         test_nis
0806         test_ntpath
0807         test_openpty
0808         test_pyexpat
0809         test_sax
0810         test_sunaudiodev
0811         test_sundry
0812         """,
0813     'sco_sv3':
0814         """
0815         test_al
0816         test_applesingle
0817         test_asynchat
0818         test_bsddb
0819         test_bsddb185
0820         test_cd
0821         test_cl
0822         test_dl
0823         test_fork1
0824         test_gettext
0825         test_gl
0826         test_imgfile
0827         test_largefile
0828         test_linuxaudiodev
0829         test_locale
0830         test_minidom
0831         test_nis
0832         test_ntpath
0833         test_openpty
0834         test_pyexpat
0835         test_queue
0836         test_sax
0837         test_sunaudiodev
0838         test_sundry
0839         test_thread
0840         test_threaded_import
0841         test_threadedtempfile
0842         test_threading
0843         """,
0844     'riscos':
0845         """
0846         test_al
0847         test_applesingle
0848         test_asynchat
0849         test_atexit
0850         test_bsddb
0851         test_bsddb185
0852         test_bsddb3
0853         test_cd
0854         test_cl
0855         test_commands
0856         test_crypt
0857         test_dbm
0858         test_dl
0859         test_fcntl
0860         test_fork1
0861         test_gdbm
0862         test_gl
0863         test_grp
0864         test_imgfile
0865         test_largefile
0866         test_linuxaudiodev
0867         test_locale
0868         test_mmap
0869         test_nis
0870         test_ntpath
0871         test_openpty
0872         test_poll
0873         test_popen2
0874         test_pty
0875         test_pwd
0876         test_strop
0877         test_sunaudiodev
0878         test_sundry
0879         test_thread
0880         test_threaded_import
0881         test_threadedtempfile
0882         test_threading
0883         test_timing
0884         """,
0885     'darwin':
0886         """
0887         test__locale
0888         test_al
0889         test_bsddb
0890         test_bsddb3
0891         test_cd
0892         test_cl
0893         test_curses
0894         test_dl
0895         test_gdbm
0896         test_gl
0897         test_imgfile
0898         test_largefile
0899         test_linuxaudiodev
0900         test_locale
0901         test_minidom
0902         test_nis
0903         test_ntpath
0904         test_ossaudiodev
0905         test_poll
0906         test_sunaudiodev
0907         """,
0908     'sunos5':
0909         """
0910         test_al
0911         test_applesingle
0912         test_bsddb
0913         test_bsddb185
0914         test_cd
0915         test_cl
0916         test_curses
0917         test_dbm
0918         test_gdbm
0919         test_gl
0920         test_gzip
0921         test_imgfile
0922         test_linuxaudiodev
0923         test_openpty
0924         test_zipfile
0925         test_zlib
0926         """,
0927     'hp-ux11':
0928         """
0929         test_al
0930         test_applesingle
0931         test_bsddb
0932         test_bsddb185
0933         test_cd
0934         test_cl
0935         test_curses
0936         test_dl
0937         test_gdbm
0938         test_gl
0939         test_gzip
0940         test_imgfile
0941         test_largefile
0942         test_linuxaudiodev
0943         test_locale
0944         test_minidom
0945         test_nis
0946         test_ntpath
0947         test_openpty
0948         test_pyexpat
0949         test_sax
0950         test_sunaudiodev
0951         test_zipfile
0952         test_zlib
0953         """,
0954     'atheos':
0955         """
0956         test_al
0957         test_applesingle
0958         test_bsddb185
0959         test_cd
0960         test_cl
0961         test_curses
0962         test_dl
0963         test_gdbm
0964         test_gl
0965         test_imgfile
0966         test_largefile
0967         test_linuxaudiodev
0968         test_locale
0969         test_mhlib
0970         test_mmap
0971         test_nis
0972         test_poll
0973         test_popen2
0974         test_resource
0975         test_sunaudiodev
0976         """,
0977     'cygwin':
0978         """
0979         test_al
0980         test_applesingle
0981         test_bsddb185
0982         test_bsddb3
0983         test_cd
0984         test_cl
0985         test_curses
0986         test_dbm
0987         test_gl
0988         test_imgfile
0989         test_ioctl
0990         test_largefile
0991         test_linuxaudiodev
0992         test_locale
0993         test_nis
0994         test_ossaudiodev
0995         test_socketserver
0996         test_sunaudiodev
0997         """,
0998     'os2emx':
0999         """
1000         test_al
1001         test_applesingle
1002         test_audioop
1003         test_bsddb185
1004         test_bsddb3
1005         test_cd
1006         test_cl
1007         test_commands
1008         test_curses
1009         test_dl
1010         test_gl
1011         test_imgfile
1012         test_largefile
1013         test_linuxaudiodev
1014         test_mhlib
1015         test_mmap
1016         test_nis
1017         test_openpty
1018         test_ossaudiodev
1019         test_pty
1020         test_resource
1021         test_signal
1022         test_sunaudiodev
1023         """,
1024     'freebsd4':
1025         """
1026         test_aepack
1027         test_al
1028         test_applesingle
1029         test_bsddb
1030         test_bsddb3
1031         test_cd
1032         test_cl
1033         test_gdbm
1034         test_gl
1035         test_imgfile
1036         test_linuxaudiodev
1037         test_locale
1038         test_macfs
1039         test_macostools
1040         test_nis
1041         test_normalization
1042         test_ossaudiodev
1043         test_pep277
1044         test_plistlib
1045         test_pty
1046         test_scriptpackages
1047         test_socket_ssl
1048         test_socketserver
1049         test_sunaudiodev
1050         test_tcl
1051         test_timeout
1052         test_unicode_file
1053         test_urllibnet
1054         test_winreg
1055         test_winsound
1056         """,
1057 }
1058 _expectations['freebsd5'] = _expectations['freebsd4']
1059 _expectations['freebsd6'] = _expectations['freebsd4']
1060 
1061 class _ExpectedSkips:
1062     def __init__(self):
1063         import os.path
1064         from test import test_normalization
1065         from test import test_socket_ssl
1066         from test import test_timeout
1067         from test import test_codecmaps_cn, test_codecmaps_jp
1068         from test import test_codecmaps_kr, test_codecmaps_tw
1069         from test import test_codecmaps_hk
1070 
1071         self.valid = False
1072         if sys.platform in _expectations:
1073             s = _expectations[sys.platform]
1074             self.expected = set(s.split())
1075 
1076             if not os.path.supports_unicode_filenames:
1077                 self.expected.add('test_pep277')
1078 
1079             if test_normalization.skip_expected:
1080                 self.expected.add('test_normalization')
1081 
1082             if test_socket_ssl.skip_expected:
1083                 self.expected.add('test_socket_ssl')
1084 
1085             if test_timeout.skip_expected:
1086                 self.expected.add('test_timeout')
1087 
1088             for cc in ('cn', 'jp', 'kr', 'tw', 'hk'):
1089                 if eval('test_codecmaps_' + cc).skip_expected:
1090                     self.expected.add('test_codecmaps_' + cc)
1091 
1092             if not sys.platform in ("mac", "darwin"):
1093                 MAC_ONLY = ["test_macostools", "test_macfs", "test_aepack",
1094                             "test_plistlib", "test_scriptpackages"]
1095                 for skip in MAC_ONLY:
1096                     self.expected.add(skip)
1097 
1098             if sys.platform != "win32":
1099                 WIN_ONLY = ["test_unicode_file", "test_winreg",
1100                             "test_winsound"]
1101                 for skip in WIN_ONLY:
1102                     self.expected.add(skip)
1103 
1104             self.valid = True
1105 
1106     def isvalid(self):
1107         "Return true iff _ExpectedSkips knows about the current platform."
1108         return self.valid
1109 
1110     def getexpected(self):
1111         """Return set of test names we expect to skip on current platform.
1112 
1113         self.isvalid() must be true.
1114         """
1115 
1116         assert self.isvalid()
1117         return self.expected
1118 
1119 if __name__ == '__main__':
1120     # Remove regrtest.py's own directory from the module search path.  This
1121     # prevents relative imports from working, and relative imports will screw
1122     # up the testing framework.  E.g. if both test.test_support and
1123     # test_support are imported, they will not contain the same globals, and
1124     # much of the testing framework relies on the globals in the
1125     # test.test_support module.
1126     mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
1127     i = pathlen = len(sys.path)
1128     while i >= 0:
1129         i -= 1
1130         if os.path.abspath(os.path.normpath(sys.path[i])) == mydir:
1131             del sys.path[i]
1132     if len(sys.path) == pathlen:
1133         print 'Could not find %r in sys.path to remove it' % mydir
1134     main()
1135 

Generated by PyXR 0.9.4
SourceForge.net Logo