Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | |
| 3 | """Regression test. |
| 4 | |
| 5 | This will find all modules whose name is "test_*" in the test |
| 6 | directory, and run them. Various command line options provide |
| 7 | additional facilities. |
| 8 | |
| 9 | Command line options: |
| 10 | |
Barry Warsaw | a873b03 | 2000-08-03 15:50:37 +0000 | [diff] [blame] | 11 | -v: verbose -- run tests in verbose mode with output to stdout |
| 12 | -q: quiet -- don't print anything except if a test fails |
| 13 | -g: generate -- write the output file for a test instead of comparing it |
| 14 | -x: exclude -- arguments are tests to *exclude* |
| 15 | -s: single -- run only a single test (see below) |
| 16 | -r: random -- randomize test execution order |
Tim Peters | c5000df | 2002-06-02 21:42:01 +0000 | [diff] [blame] | 17 | -f: fromfile -- read names of tests to run from a file (see below) |
Neil Schemenauer | 8a00abc | 2000-10-13 01:32:42 +0000 | [diff] [blame] | 18 | -l: findleaks -- if GC is available detect tests that leak memory |
Barry Warsaw | 08fca52 | 2001-08-20 22:33:46 +0000 | [diff] [blame] | 19 | -u: use -- specify which special resource intensive tests to run |
| 20 | -h: help -- print this text and exit |
Guido van Rossum | 9e9d4f8 | 2002-06-07 15:17:03 +0000 | [diff] [blame] | 21 | -t: threshold -- call gc.set_threshold(N) |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 22 | |
| 23 | If non-option arguments are present, they are names for tests to run, |
| 24 | unless -x is given, in which case they are names for tests not to run. |
| 25 | If no test names are given, all tests are run. |
Guido van Rossum | f58ed25 | 1997-03-07 21:04:33 +0000 | [diff] [blame] | 26 | |
Guido van Rossum | a412220 | 1997-08-18 20:08:24 +0000 | [diff] [blame] | 27 | -v is incompatible with -g and does not compare test output files. |
Barry Warsaw | e11e3de | 1999-01-28 19:51:51 +0000 | [diff] [blame] | 28 | |
Guido van Rossum | 9e9d4f8 | 2002-06-07 15:17:03 +0000 | [diff] [blame] | 29 | -s means to run only a single test and exit. This is useful when |
| 30 | doing memory analysis on the Python interpreter (which tend to consume |
| 31 | too many resources to run the full regression test non-stop). The |
| 32 | file /tmp/pynexttest is read to find the next test to run. If this |
| 33 | file is missing, the first test_*.py file in testdir or on the command |
| 34 | line is used. (actually tempfile.gettempdir() is used instead of |
| 35 | /tmp). |
Barry Warsaw | e11e3de | 1999-01-28 19:51:51 +0000 | [diff] [blame] | 36 | |
Guido van Rossum | 9e9d4f8 | 2002-06-07 15:17:03 +0000 | [diff] [blame] | 37 | -f reads the names of tests from the file given as f's argument, one |
| 38 | or more test names per line. Whitespace is ignored. Blank lines and |
| 39 | lines beginning with '#' are ignored. This is especially useful for |
| 40 | whittling down failures involving interactions among tests. |
Tim Peters | c5000df | 2002-06-02 21:42:01 +0000 | [diff] [blame] | 41 | |
Guido van Rossum | 9e9d4f8 | 2002-06-07 15:17:03 +0000 | [diff] [blame] | 42 | -u is used to specify which special resource intensive tests to run, |
| 43 | such as those requiring large file support or network connectivity. |
| 44 | The argument is a comma-separated list of words indicating the |
| 45 | resources to test. Currently only the following are defined: |
Barry Warsaw | 08fca52 | 2001-08-20 22:33:46 +0000 | [diff] [blame] | 46 | |
Fred Drake | 3a15dac | 2002-04-11 16:39:16 +0000 | [diff] [blame] | 47 | all - Enable all special resources. |
| 48 | |
Guido van Rossum | 315aa36 | 2003-03-11 14:46:48 +0000 | [diff] [blame] | 49 | audio - Tests that use the audio device. (There are known |
| 50 | cases of broken audio drivers that can crash Python or |
| 51 | even the Linux kernel.) |
| 52 | |
Andrew M. Kuchling | 2158df0 | 2001-10-22 15:26:09 +0000 | [diff] [blame] | 53 | curses - Tests that use curses and will modify the terminal's |
| 54 | state and output modes. |
Tim Peters | 1633a2e | 2001-10-30 05:56:40 +0000 | [diff] [blame] | 55 | |
Guido van Rossum | 9e9d4f8 | 2002-06-07 15:17:03 +0000 | [diff] [blame] | 56 | largefile - It is okay to run some test that may create huge |
| 57 | files. These tests can take a long time and may |
| 58 | consume >2GB of disk space temporarily. |
Barry Warsaw | 08fca52 | 2001-08-20 22:33:46 +0000 | [diff] [blame] | 59 | |
Guido van Rossum | 9e9d4f8 | 2002-06-07 15:17:03 +0000 | [diff] [blame] | 60 | network - It is okay to run tests that use external network |
| 61 | resource, e.g. testing SSL support for sockets. |
Martin v. Löwis | 1c6b1a2 | 2002-11-19 17:47:07 +0000 | [diff] [blame] | 62 | |
| 63 | bsddb - It is okay to run the bsddb testsuite, which takes |
| 64 | a long time to complete. |
Fred Drake | 4dd0f7e | 2002-11-26 21:44:56 +0000 | [diff] [blame] | 65 | |
| 66 | To enable all resources except one, use '-uall,-<resource>'. For |
| 67 | example, to run all the tests except for the bsddb tests, give the |
| 68 | option '-uall,-bsddb'. |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 69 | """ |
| 70 | |
| 71 | import sys |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 72 | import os |
| 73 | import getopt |
Guido van Rossum | 9e48b27 | 1997-07-16 01:56:13 +0000 | [diff] [blame] | 74 | import traceback |
Skip Montanaro | ab1c791 | 2000-06-30 16:39:27 +0000 | [diff] [blame] | 75 | import random |
Raymond Hettinger | 74e6766 | 2003-05-17 20:44:12 +0000 | [diff] [blame^] | 76 | import cStringIO |
Guido van Rossum | dc15c27 | 2002-08-12 21:55:51 +0000 | [diff] [blame] | 77 | import warnings |
Tim Peters | 7c7efe9 | 2002-08-23 17:55:54 +0000 | [diff] [blame] | 78 | from sets import Set |
Guido van Rossum | dc15c27 | 2002-08-12 21:55:51 +0000 | [diff] [blame] | 79 | |
| 80 | # I see no other way to suppress these warnings; |
| 81 | # putting them in test_grammar.py has no effect: |
Guido van Rossum | 88b1def | 2002-08-14 17:54:48 +0000 | [diff] [blame] | 82 | warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning, |
Guido van Rossum | dc15c27 | 2002-08-12 21:55:51 +0000 | [diff] [blame] | 83 | ".*test.test_grammar$") |
Guido van Rossum | c34c4fc | 2002-09-19 00:42:16 +0000 | [diff] [blame] | 84 | if sys.maxint > 0x7fffffff: |
| 85 | # Also suppress them in <string>, because for 64-bit platforms, |
| 86 | # that's where test_grammar.py hides them. |
| 87 | warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning, |
| 88 | "<string>") |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 89 | |
Guido van Rossum | bb48465 | 2002-12-02 09:56:21 +0000 | [diff] [blame] | 90 | # MacOSX (a.k.a. Darwin) has a default stack size that is too small |
| 91 | # for deeply recursive regular expressions. We see this as crashes in |
| 92 | # the Python test suite when running test_re.py and test_sre.py. The |
| 93 | # fix is to set the stack limit to 2048. |
| 94 | # This approach may also be useful for other Unixy platforms that |
| 95 | # suffer from small default stack limits. |
| 96 | if sys.platform == 'darwin': |
| 97 | try: |
| 98 | import resource |
| 99 | except ImportError: |
| 100 | pass |
| 101 | else: |
| 102 | soft, hard = resource.getrlimit(resource.RLIMIT_STACK) |
| 103 | newsoft = min(hard, max(soft, 1024*2048)) |
| 104 | resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard)) |
| 105 | |
Barry Warsaw | 04f357c | 2002-07-23 19:04:11 +0000 | [diff] [blame] | 106 | from test import test_support |
Fred Drake | 3a15dac | 2002-04-11 16:39:16 +0000 | [diff] [blame] | 107 | |
Guido van Rossum | 315aa36 | 2003-03-11 14:46:48 +0000 | [diff] [blame] | 108 | RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb') |
Fred Drake | 3a15dac | 2002-04-11 16:39:16 +0000 | [diff] [blame] | 109 | |
| 110 | |
Barry Warsaw | 08fca52 | 2001-08-20 22:33:46 +0000 | [diff] [blame] | 111 | def usage(code, msg=''): |
| 112 | print __doc__ |
| 113 | if msg: print msg |
| 114 | sys.exit(code) |
| 115 | |
| 116 | |
Skip Montanaro | ab1c791 | 2000-06-30 16:39:27 +0000 | [diff] [blame] | 117 | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, |
Tim Peters | c5000df | 2002-06-02 21:42:01 +0000 | [diff] [blame] | 118 | exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, |
Barry Warsaw | 08fca52 | 2001-08-20 22:33:46 +0000 | [diff] [blame] | 119 | use_resources=None): |
Guido van Rossum | 6fd83b7 | 1998-08-01 17:04:08 +0000 | [diff] [blame] | 120 | """Execute a test suite. |
| 121 | |
Thomas Wouters | 7e47402 | 2000-07-16 12:04:32 +0000 | [diff] [blame] | 122 | This also parses command-line options and modifies its behavior |
Fred Drake | 004d5e6 | 2000-10-23 17:22:08 +0000 | [diff] [blame] | 123 | accordingly. |
Guido van Rossum | 6fd83b7 | 1998-08-01 17:04:08 +0000 | [diff] [blame] | 124 | |
| 125 | tests -- a list of strings containing test names (optional) |
| 126 | testdir -- the directory in which to look for tests (optional) |
| 127 | |
| 128 | Users other than the Python test suite will certainly want to |
| 129 | specify testdir; if it's omitted, the directory containing the |
Fred Drake | 004d5e6 | 2000-10-23 17:22:08 +0000 | [diff] [blame] | 130 | Python test suite is searched for. |
Guido van Rossum | 6fd83b7 | 1998-08-01 17:04:08 +0000 | [diff] [blame] | 131 | |
| 132 | If the tests argument is omitted, the tests listed on the |
| 133 | command-line will be used. If that's empty, too, then all *.py |
| 134 | files beginning with test_ will be used. |
Skip Montanaro | ab1c791 | 2000-06-30 16:39:27 +0000 | [diff] [blame] | 135 | |
Guido van Rossum | 9e9d4f8 | 2002-06-07 15:17:03 +0000 | [diff] [blame] | 136 | The other default arguments (verbose, quiet, generate, exclude, |
| 137 | single, randomize, findleaks, and use_resources) allow programmers |
| 138 | calling main() directly to set the values that would normally be |
| 139 | set by flags on the command line. |
Barry Warsaw | a873b03 | 2000-08-03 15:50:37 +0000 | [diff] [blame] | 140 | |
Guido van Rossum | 6fd83b7 | 1998-08-01 17:04:08 +0000 | [diff] [blame] | 141 | """ |
Fred Drake | 004d5e6 | 2000-10-23 17:22:08 +0000 | [diff] [blame] | 142 | |
Tim Peters | 8dee809 | 2001-09-25 20:05:11 +0000 | [diff] [blame] | 143 | test_support.record_original_stdout(sys.stdout) |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 144 | try: |
Guido van Rossum | 9e9d4f8 | 2002-06-07 15:17:03 +0000 | [diff] [blame] | 145 | opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', |
Barry Warsaw | 08fca52 | 2001-08-20 22:33:46 +0000 | [diff] [blame] | 146 | ['help', 'verbose', 'quiet', 'generate', |
Tim Peters | c5000df | 2002-06-02 21:42:01 +0000 | [diff] [blame] | 147 | 'exclude', 'single', 'random', 'fromfile', |
Guido van Rossum | 9e9d4f8 | 2002-06-07 15:17:03 +0000 | [diff] [blame] | 148 | 'findleaks', 'use=', 'threshold=']) |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 149 | except getopt.error, msg: |
Barry Warsaw | 08fca52 | 2001-08-20 22:33:46 +0000 | [diff] [blame] | 150 | usage(2, msg) |
| 151 | |
| 152 | # Defaults |
| 153 | if use_resources is None: |
| 154 | use_resources = [] |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 155 | for o, a in opts: |
Barry Warsaw | 08fca52 | 2001-08-20 22:33:46 +0000 | [diff] [blame] | 156 | if o in ('-h', '--help'): |
| 157 | usage(0) |
| 158 | elif o in ('-v', '--verbose'): |
| 159 | verbose += 1 |
| 160 | elif o in ('-q', '--quiet'): |
| 161 | quiet = 1; |
| 162 | verbose = 0 |
| 163 | elif o in ('-g', '--generate'): |
| 164 | generate = 1 |
| 165 | elif o in ('-x', '--exclude'): |
| 166 | exclude = 1 |
| 167 | elif o in ('-s', '--single'): |
| 168 | single = 1 |
| 169 | elif o in ('-r', '--randomize'): |
| 170 | randomize = 1 |
Tim Peters | c5000df | 2002-06-02 21:42:01 +0000 | [diff] [blame] | 171 | elif o in ('-f', '--fromfile'): |
| 172 | fromfile = a |
Barry Warsaw | 08fca52 | 2001-08-20 22:33:46 +0000 | [diff] [blame] | 173 | elif o in ('-l', '--findleaks'): |
| 174 | findleaks = 1 |
Guido van Rossum | 9e9d4f8 | 2002-06-07 15:17:03 +0000 | [diff] [blame] | 175 | elif o in ('-t', '--threshold'): |
| 176 | import gc |
| 177 | gc.set_threshold(int(a)) |
Barry Warsaw | 08fca52 | 2001-08-20 22:33:46 +0000 | [diff] [blame] | 178 | elif o in ('-u', '--use'): |
Guido van Rossum | fe3f696 | 2001-09-06 16:09:41 +0000 | [diff] [blame] | 179 | u = [x.lower() for x in a.split(',')] |
| 180 | for r in u: |
Fred Drake | 3a15dac | 2002-04-11 16:39:16 +0000 | [diff] [blame] | 181 | if r == 'all': |
Fred Drake | 4dd0f7e | 2002-11-26 21:44:56 +0000 | [diff] [blame] | 182 | use_resources[:] = RESOURCE_NAMES |
| 183 | continue |
| 184 | remove = False |
| 185 | if r[0] == '-': |
| 186 | remove = True |
| 187 | r = r[1:] |
Fred Drake | 3a15dac | 2002-04-11 16:39:16 +0000 | [diff] [blame] | 188 | if r not in RESOURCE_NAMES: |
| 189 | usage(1, 'Invalid -u/--use option: ' + a) |
Fred Drake | 4dd0f7e | 2002-11-26 21:44:56 +0000 | [diff] [blame] | 190 | if remove: |
| 191 | if r in use_resources: |
| 192 | use_resources.remove(r) |
| 193 | elif r not in use_resources: |
Andrew MacIntyre | e41abab | 2002-04-30 12:11:04 +0000 | [diff] [blame] | 194 | use_resources.append(r) |
Guido van Rossum | a412220 | 1997-08-18 20:08:24 +0000 | [diff] [blame] | 195 | if generate and verbose: |
Barry Warsaw | 08fca52 | 2001-08-20 22:33:46 +0000 | [diff] [blame] | 196 | usage(2, "-g and -v don't go together!") |
Tim Peters | c5000df | 2002-06-02 21:42:01 +0000 | [diff] [blame] | 197 | if single and fromfile: |
| 198 | usage(2, "-s and -f don't go together!") |
Barry Warsaw | 08fca52 | 2001-08-20 22:33:46 +0000 | [diff] [blame] | 199 | |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 200 | good = [] |
| 201 | bad = [] |
| 202 | skipped = [] |
Fred Drake | 9a0db07 | 2003-02-03 15:19:30 +0000 | [diff] [blame] | 203 | resource_denieds = [] |
Barry Warsaw | e11e3de | 1999-01-28 19:51:51 +0000 | [diff] [blame] | 204 | |
Neil Schemenauer | d569f23 | 2000-09-22 15:29:28 +0000 | [diff] [blame] | 205 | if findleaks: |
Barry Warsaw | a873b03 | 2000-08-03 15:50:37 +0000 | [diff] [blame] | 206 | try: |
| 207 | import gc |
| 208 | except ImportError: |
Neil Schemenauer | 8a00abc | 2000-10-13 01:32:42 +0000 | [diff] [blame] | 209 | print 'No GC available, disabling findleaks.' |
Neil Schemenauer | d569f23 | 2000-09-22 15:29:28 +0000 | [diff] [blame] | 210 | findleaks = 0 |
Barry Warsaw | a873b03 | 2000-08-03 15:50:37 +0000 | [diff] [blame] | 211 | else: |
Neil Schemenauer | 8a00abc | 2000-10-13 01:32:42 +0000 | [diff] [blame] | 212 | # Uncomment the line below to report garbage that is not |
| 213 | # freeable by reference counting alone. By default only |
| 214 | # garbage that is not collectable by the GC is reported. |
| 215 | #gc.set_debug(gc.DEBUG_SAVEALL) |
Neil Schemenauer | d569f23 | 2000-09-22 15:29:28 +0000 | [diff] [blame] | 216 | found_garbage = [] |
Barry Warsaw | a873b03 | 2000-08-03 15:50:37 +0000 | [diff] [blame] | 217 | |
Barry Warsaw | e11e3de | 1999-01-28 19:51:51 +0000 | [diff] [blame] | 218 | if single: |
| 219 | from tempfile import gettempdir |
| 220 | filename = os.path.join(gettempdir(), 'pynexttest') |
| 221 | try: |
| 222 | fp = open(filename, 'r') |
Eric S. Raymond | fc170b1 | 2001-02-09 11:51:27 +0000 | [diff] [blame] | 223 | next = fp.read().strip() |
Barry Warsaw | e11e3de | 1999-01-28 19:51:51 +0000 | [diff] [blame] | 224 | tests = [next] |
| 225 | fp.close() |
| 226 | except IOError: |
| 227 | pass |
Tim Peters | c5000df | 2002-06-02 21:42:01 +0000 | [diff] [blame] | 228 | |
| 229 | if fromfile: |
| 230 | tests = [] |
| 231 | fp = open(fromfile) |
| 232 | for line in fp: |
| 233 | guts = line.split() # assuming no test has whitespace in its name |
| 234 | if guts and not guts[0].startswith('#'): |
| 235 | tests.extend(guts) |
| 236 | fp.close() |
| 237 | |
| 238 | # Strip .py extensions. |
| 239 | if args: |
| 240 | args = map(removepy, args) |
| 241 | if tests: |
| 242 | tests = map(removepy, tests) |
| 243 | |
Guido van Rossum | 6c74fea | 1998-08-25 12:29:08 +0000 | [diff] [blame] | 244 | stdtests = STDTESTS[:] |
| 245 | nottests = NOTTESTS[:] |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 246 | if exclude: |
Guido van Rossum | 6c74fea | 1998-08-25 12:29:08 +0000 | [diff] [blame] | 247 | for arg in args: |
| 248 | if arg in stdtests: |
| 249 | stdtests.remove(arg) |
| 250 | nottests[:0] = args |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 251 | args = [] |
Guido van Rossum | 747e1ca | 1998-08-24 13:48:36 +0000 | [diff] [blame] | 252 | tests = tests or args or findtests(testdir, stdtests, nottests) |
Barry Warsaw | e11e3de | 1999-01-28 19:51:51 +0000 | [diff] [blame] | 253 | if single: |
| 254 | tests = tests[:1] |
Skip Montanaro | ab1c791 | 2000-06-30 16:39:27 +0000 | [diff] [blame] | 255 | if randomize: |
| 256 | random.shuffle(tests) |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 257 | test_support.verbose = verbose # Tell tests to be moderately quiet |
Barry Warsaw | 08fca52 | 2001-08-20 22:33:46 +0000 | [diff] [blame] | 258 | test_support.use_resources = use_resources |
Guido van Rossum | 5796d26 | 2000-04-21 21:35:06 +0000 | [diff] [blame] | 259 | save_modules = sys.modules.keys() |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 260 | for test in tests: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 261 | if not quiet: |
| 262 | print test |
Guido van Rossum | 3cda93e | 2002-09-13 21:28:03 +0000 | [diff] [blame] | 263 | sys.stdout.flush() |
Trent Mick | f29f47b | 2000-08-11 19:02:59 +0000 | [diff] [blame] | 264 | ok = runtest(test, generate, verbose, quiet, testdir) |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 265 | if ok > 0: |
| 266 | good.append(test) |
| 267 | elif ok == 0: |
| 268 | bad.append(test) |
| 269 | else: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 270 | skipped.append(test) |
Fred Drake | 9a0db07 | 2003-02-03 15:19:30 +0000 | [diff] [blame] | 271 | if ok == -2: |
| 272 | resource_denieds.append(test) |
Neil Schemenauer | d569f23 | 2000-09-22 15:29:28 +0000 | [diff] [blame] | 273 | if findleaks: |
| 274 | gc.collect() |
| 275 | if gc.garbage: |
Neil Schemenauer | 8a00abc | 2000-10-13 01:32:42 +0000 | [diff] [blame] | 276 | print "Warning: test created", len(gc.garbage), |
| 277 | print "uncollectable object(s)." |
| 278 | # move the uncollectable objects somewhere so we don't see |
| 279 | # them again |
Neil Schemenauer | d569f23 | 2000-09-22 15:29:28 +0000 | [diff] [blame] | 280 | found_garbage.extend(gc.garbage) |
| 281 | del gc.garbage[:] |
Guido van Rossum | 5796d26 | 2000-04-21 21:35:06 +0000 | [diff] [blame] | 282 | # Unload the newly imported modules (best effort finalization) |
| 283 | for module in sys.modules.keys(): |
Guido van Rossum | 5193114 | 2000-05-05 14:27:39 +0000 | [diff] [blame] | 284 | if module not in save_modules and module.startswith("test."): |
Guido van Rossum | 5796d26 | 2000-04-21 21:35:06 +0000 | [diff] [blame] | 285 | test_support.unload(module) |
Jeremy Hylton | 7a1ea0e | 2001-10-17 13:45:28 +0000 | [diff] [blame] | 286 | |
| 287 | # The lists won't be sorted if running with -r |
| 288 | good.sort() |
| 289 | bad.sort() |
| 290 | skipped.sort() |
Tim Peters | e0c446b | 2001-10-18 21:57:37 +0000 | [diff] [blame] | 291 | |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 292 | if good and not quiet: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 293 | if not bad and not skipped and len(good) > 1: |
| 294 | print "All", |
| 295 | print count(len(good), "test"), "OK." |
Tim Peters | 1a4d77b | 2000-12-30 22:21:22 +0000 | [diff] [blame] | 296 | if verbose: |
Barry Warsaw | 408b6d3 | 2002-07-30 23:27:12 +0000 | [diff] [blame] | 297 | print "CAUTION: stdout isn't compared in verbose mode:" |
| 298 | print "a test that passes in verbose mode may fail without it." |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 299 | if bad: |
Tim Peters | a45da92 | 2001-08-12 03:45:50 +0000 | [diff] [blame] | 300 | print count(len(bad), "test"), "failed:" |
| 301 | printlist(bad) |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 302 | if skipped and not quiet: |
Tim Peters | a45da92 | 2001-08-12 03:45:50 +0000 | [diff] [blame] | 303 | print count(len(skipped), "test"), "skipped:" |
| 304 | printlist(skipped) |
Barry Warsaw | e11e3de | 1999-01-28 19:51:51 +0000 | [diff] [blame] | 305 | |
Tim Peters | b5b7b78 | 2001-08-12 01:20:39 +0000 | [diff] [blame] | 306 | e = _ExpectedSkips() |
Tim Peters | a2be2d6 | 2001-08-12 02:01:09 +0000 | [diff] [blame] | 307 | plat = sys.platform |
Tim Peters | b5b7b78 | 2001-08-12 01:20:39 +0000 | [diff] [blame] | 308 | if e.isvalid(): |
Fred Drake | 9a0db07 | 2003-02-03 15:19:30 +0000 | [diff] [blame] | 309 | surprise = Set(skipped) - e.getexpected() - Set(resource_denieds) |
Tim Peters | b5b7b78 | 2001-08-12 01:20:39 +0000 | [diff] [blame] | 310 | if surprise: |
| 311 | print count(len(surprise), "skip"), \ |
Tim Peters | a45da92 | 2001-08-12 03:45:50 +0000 | [diff] [blame] | 312 | "unexpected on", plat + ":" |
| 313 | printlist(surprise) |
Tim Peters | b5b7b78 | 2001-08-12 01:20:39 +0000 | [diff] [blame] | 314 | else: |
| 315 | print "Those skips are all expected on", plat + "." |
| 316 | else: |
| 317 | print "Ask someone to teach regrtest.py about which tests are" |
| 318 | print "expected to get skipped on", plat + "." |
| 319 | |
Barry Warsaw | e11e3de | 1999-01-28 19:51:51 +0000 | [diff] [blame] | 320 | if single: |
| 321 | alltests = findtests(testdir, stdtests, nottests) |
| 322 | for i in range(len(alltests)): |
| 323 | if tests[0] == alltests[i]: |
| 324 | if i == len(alltests) - 1: |
| 325 | os.unlink(filename) |
| 326 | else: |
| 327 | fp = open(filename, 'w') |
| 328 | fp.write(alltests[i+1] + '\n') |
| 329 | fp.close() |
| 330 | break |
| 331 | else: |
| 332 | os.unlink(filename) |
| 333 | |
Barry Warsaw | 08fca52 | 2001-08-20 22:33:46 +0000 | [diff] [blame] | 334 | sys.exit(len(bad) > 0) |
| 335 | |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 336 | |
Guido van Rossum | 6fd83b7 | 1998-08-01 17:04:08 +0000 | [diff] [blame] | 337 | STDTESTS = [ |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 338 | 'test_grammar', |
| 339 | 'test_opcodes', |
| 340 | 'test_operations', |
| 341 | 'test_builtin', |
| 342 | 'test_exceptions', |
| 343 | 'test_types', |
| 344 | ] |
| 345 | |
Guido van Rossum | 6fd83b7 | 1998-08-01 17:04:08 +0000 | [diff] [blame] | 346 | NOTTESTS = [ |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 347 | 'test_support', |
Jeremy Hylton | 62e2c7e | 2001-02-28 17:48:06 +0000 | [diff] [blame] | 348 | 'test_future1', |
| 349 | 'test_future2', |
Jeremy Hylton | 8471a35 | 2001-08-20 20:33:42 +0000 | [diff] [blame] | 350 | 'test_future3', |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 351 | ] |
| 352 | |
Guido van Rossum | 6fd83b7 | 1998-08-01 17:04:08 +0000 | [diff] [blame] | 353 | def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS): |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 354 | """Return a list of all applicable test modules.""" |
Guido van Rossum | 6fd83b7 | 1998-08-01 17:04:08 +0000 | [diff] [blame] | 355 | if not testdir: testdir = findtestdir() |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 356 | names = os.listdir(testdir) |
| 357 | tests = [] |
| 358 | for name in names: |
Guido van Rossum | e2ae77b | 2001-10-24 20:42:55 +0000 | [diff] [blame] | 359 | if name[:5] == "test_" and name[-3:] == os.extsep+"py": |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 360 | modname = name[:-3] |
| 361 | if modname not in stdtests and modname not in nottests: |
| 362 | tests.append(modname) |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 363 | tests.sort() |
| 364 | return stdtests + tests |
| 365 | |
Trent Mick | f29f47b | 2000-08-11 19:02:59 +0000 | [diff] [blame] | 366 | def runtest(test, generate, verbose, quiet, testdir = None): |
Guido van Rossum | 6fd83b7 | 1998-08-01 17:04:08 +0000 | [diff] [blame] | 367 | """Run a single test. |
| 368 | test -- the name of the test |
| 369 | generate -- if true, generate output, instead of running the test |
| 370 | and comparing it to a previously created output file |
| 371 | verbose -- if true, print more messages |
Trent Mick | f29f47b | 2000-08-11 19:02:59 +0000 | [diff] [blame] | 372 | quiet -- if true, don't print 'skipped' messages (probably redundant) |
Guido van Rossum | 6fd83b7 | 1998-08-01 17:04:08 +0000 | [diff] [blame] | 373 | testdir -- test directory |
| 374 | """ |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 375 | test_support.unload(test) |
Guido van Rossum | 6fd83b7 | 1998-08-01 17:04:08 +0000 | [diff] [blame] | 376 | if not testdir: testdir = findtestdir() |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 377 | outputdir = os.path.join(testdir, "output") |
| 378 | outputfile = os.path.join(outputdir, test) |
Tim Peters | 9390cc1 | 2001-09-28 20:14:46 +0000 | [diff] [blame] | 379 | if verbose: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 380 | cfp = None |
Guido van Rossum | 0fcca4e | 2001-09-21 20:31:52 +0000 | [diff] [blame] | 381 | else: |
Raymond Hettinger | 74e6766 | 2003-05-17 20:44:12 +0000 | [diff] [blame^] | 382 | cfp = cStringIO.StringIO() |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 383 | try: |
Tim Peters | 342ca75 | 2001-09-25 19:13:20 +0000 | [diff] [blame] | 384 | save_stdout = sys.stdout |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 385 | try: |
| 386 | if cfp: |
| 387 | sys.stdout = cfp |
| 388 | print test # Output file starts with test name |
Barry Warsaw | 408b6d3 | 2002-07-30 23:27:12 +0000 | [diff] [blame] | 389 | if test.startswith('test.'): |
| 390 | abstest = test |
| 391 | else: |
| 392 | # Always import it from the test package |
| 393 | abstest = 'test.' + test |
| 394 | the_package = __import__(abstest, globals(), locals(), []) |
| 395 | the_module = getattr(the_package, test) |
Tim Peters | d974221 | 2001-05-22 18:28:25 +0000 | [diff] [blame] | 396 | # Most tests run to completion simply as a side-effect of |
| 397 | # being imported. For the benefit of tests that can't run |
| 398 | # that way (like test_threaded_import), explicitly invoke |
| 399 | # their test_main() function (if it exists). |
| 400 | indirect_test = getattr(the_module, "test_main", None) |
| 401 | if indirect_test is not None: |
| 402 | indirect_test() |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 403 | finally: |
Tim Peters | 342ca75 | 2001-09-25 19:13:20 +0000 | [diff] [blame] | 404 | sys.stdout = save_stdout |
Fred Drake | 9a0db07 | 2003-02-03 15:19:30 +0000 | [diff] [blame] | 405 | except test_support.ResourceDenied, msg: |
| 406 | if not quiet: |
| 407 | print test, "skipped --", msg |
| 408 | sys.stdout.flush() |
| 409 | return -2 |
Thomas Wouters | 3af826e | 2000-08-04 13:17:51 +0000 | [diff] [blame] | 410 | except (ImportError, test_support.TestSkipped), msg: |
Trent Mick | f29f47b | 2000-08-11 19:02:59 +0000 | [diff] [blame] | 411 | if not quiet: |
Fred Drake | de4742b | 2002-10-17 20:36:08 +0000 | [diff] [blame] | 412 | print test, "skipped --", msg |
Guido van Rossum | 3cda93e | 2002-09-13 21:28:03 +0000 | [diff] [blame] | 413 | sys.stdout.flush() |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 414 | return -1 |
Fred Drake | fe5c22a | 2000-08-18 16:04:05 +0000 | [diff] [blame] | 415 | except KeyboardInterrupt: |
| 416 | raise |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 417 | except test_support.TestFailed, msg: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 418 | print "test", test, "failed --", msg |
Guido van Rossum | 3cda93e | 2002-09-13 21:28:03 +0000 | [diff] [blame] | 419 | sys.stdout.flush() |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 420 | return 0 |
Guido van Rossum | 9e48b27 | 1997-07-16 01:56:13 +0000 | [diff] [blame] | 421 | except: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 422 | type, value = sys.exc_info()[:2] |
Fred Drake | 27c4b39 | 2000-08-23 20:34:40 +0000 | [diff] [blame] | 423 | print "test", test, "crashed --", str(type) + ":", value |
Guido van Rossum | 3cda93e | 2002-09-13 21:28:03 +0000 | [diff] [blame] | 424 | sys.stdout.flush() |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 425 | if verbose: |
| 426 | traceback.print_exc(file=sys.stdout) |
Guido van Rossum | 3cda93e | 2002-09-13 21:28:03 +0000 | [diff] [blame] | 427 | sys.stdout.flush() |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 428 | return 0 |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 429 | else: |
Guido van Rossum | 0fcca4e | 2001-09-21 20:31:52 +0000 | [diff] [blame] | 430 | if not cfp: |
| 431 | return 1 |
| 432 | output = cfp.getvalue() |
Fred Drake | e51fe8d | 2001-05-29 17:10:51 +0000 | [diff] [blame] | 433 | if generate: |
Fred Drake | e51fe8d | 2001-05-29 17:10:51 +0000 | [diff] [blame] | 434 | if output == test + "\n": |
| 435 | if os.path.exists(outputfile): |
| 436 | # Write it since it already exists (and the contents |
| 437 | # may have changed), but let the user know it isn't |
| 438 | # needed: |
Fred Drake | e51fe8d | 2001-05-29 17:10:51 +0000 | [diff] [blame] | 439 | print "output file", outputfile, \ |
| 440 | "is no longer needed; consider removing it" |
Guido van Rossum | 0fcca4e | 2001-09-21 20:31:52 +0000 | [diff] [blame] | 441 | else: |
| 442 | # We don't need it, so don't create it. |
| 443 | return 1 |
| 444 | fp = open(outputfile, "w") |
| 445 | fp.write(output) |
| 446 | fp.close() |
| 447 | return 1 |
| 448 | if os.path.exists(outputfile): |
| 449 | fp = open(outputfile, "r") |
| 450 | expected = fp.read() |
| 451 | fp.close() |
| 452 | else: |
| 453 | expected = test + "\n" |
| 454 | if output == expected: |
| 455 | return 1 |
| 456 | print "test", test, "produced unexpected output:" |
Guido van Rossum | 3cda93e | 2002-09-13 21:28:03 +0000 | [diff] [blame] | 457 | sys.stdout.flush() |
Guido van Rossum | 0fcca4e | 2001-09-21 20:31:52 +0000 | [diff] [blame] | 458 | reportdiff(expected, output) |
Guido van Rossum | 3cda93e | 2002-09-13 21:28:03 +0000 | [diff] [blame] | 459 | sys.stdout.flush() |
Guido van Rossum | 0fcca4e | 2001-09-21 20:31:52 +0000 | [diff] [blame] | 460 | return 0 |
| 461 | |
| 462 | def reportdiff(expected, output): |
Guido van Rossum | 0fcca4e | 2001-09-21 20:31:52 +0000 | [diff] [blame] | 463 | import difflib |
Tim Peters | c377b16 | 2001-09-22 05:31:03 +0000 | [diff] [blame] | 464 | print "*" * 70 |
| 465 | a = expected.splitlines(1) |
| 466 | b = output.splitlines(1) |
Guido van Rossum | cf69193 | 2001-09-21 21:06:22 +0000 | [diff] [blame] | 467 | sm = difflib.SequenceMatcher(a=a, b=b) |
| 468 | tuples = sm.get_opcodes() |
Tim Peters | c377b16 | 2001-09-22 05:31:03 +0000 | [diff] [blame] | 469 | |
Guido van Rossum | cf69193 | 2001-09-21 21:06:22 +0000 | [diff] [blame] | 470 | def pair(x0, x1): |
Tim Peters | c377b16 | 2001-09-22 05:31:03 +0000 | [diff] [blame] | 471 | # x0:x1 are 0-based slice indices; convert to 1-based line indices. |
Guido van Rossum | cf69193 | 2001-09-21 21:06:22 +0000 | [diff] [blame] | 472 | x0 += 1 |
| 473 | if x0 >= x1: |
Tim Peters | c377b16 | 2001-09-22 05:31:03 +0000 | [diff] [blame] | 474 | return "line " + str(x0) |
Guido van Rossum | cf69193 | 2001-09-21 21:06:22 +0000 | [diff] [blame] | 475 | else: |
Tim Peters | c377b16 | 2001-09-22 05:31:03 +0000 | [diff] [blame] | 476 | return "lines %d-%d" % (x0, x1) |
| 477 | |
Guido van Rossum | cf69193 | 2001-09-21 21:06:22 +0000 | [diff] [blame] | 478 | for op, a0, a1, b0, b1 in tuples: |
| 479 | if op == 'equal': |
| 480 | pass |
Tim Peters | c377b16 | 2001-09-22 05:31:03 +0000 | [diff] [blame] | 481 | |
Guido van Rossum | cf69193 | 2001-09-21 21:06:22 +0000 | [diff] [blame] | 482 | elif op == 'delete': |
Tim Peters | c377b16 | 2001-09-22 05:31:03 +0000 | [diff] [blame] | 483 | print "***", pair(a0, a1), "of expected output missing:" |
Guido van Rossum | cf69193 | 2001-09-21 21:06:22 +0000 | [diff] [blame] | 484 | for line in a[a0:a1]: |
Tim Peters | c377b16 | 2001-09-22 05:31:03 +0000 | [diff] [blame] | 485 | print "-", line, |
| 486 | |
Guido van Rossum | cf69193 | 2001-09-21 21:06:22 +0000 | [diff] [blame] | 487 | elif op == 'replace': |
Tim Peters | c377b16 | 2001-09-22 05:31:03 +0000 | [diff] [blame] | 488 | print "*** mismatch between", pair(a0, a1), "of expected", \ |
| 489 | "output and", pair(b0, b1), "of actual output:" |
| 490 | for line in difflib.ndiff(a[a0:a1], b[b0:b1]): |
| 491 | print line, |
| 492 | |
Guido van Rossum | cf69193 | 2001-09-21 21:06:22 +0000 | [diff] [blame] | 493 | elif op == 'insert': |
Tim Peters | c377b16 | 2001-09-22 05:31:03 +0000 | [diff] [blame] | 494 | print "***", pair(b0, b1), "of actual output doesn't appear", \ |
| 495 | "in expected output after line", str(a1)+":" |
Guido van Rossum | cf69193 | 2001-09-21 21:06:22 +0000 | [diff] [blame] | 496 | for line in b[b0:b1]: |
Tim Peters | c377b16 | 2001-09-22 05:31:03 +0000 | [diff] [blame] | 497 | print "+", line, |
| 498 | |
Guido van Rossum | cf69193 | 2001-09-21 21:06:22 +0000 | [diff] [blame] | 499 | else: |
| 500 | print "get_opcodes() returned bad tuple?!?!", (op, a0, a1, b0, b1) |
Tim Peters | c377b16 | 2001-09-22 05:31:03 +0000 | [diff] [blame] | 501 | |
Guido van Rossum | 0fcca4e | 2001-09-21 20:31:52 +0000 | [diff] [blame] | 502 | print "*" * 70 |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 503 | |
| 504 | def findtestdir(): |
| 505 | if __name__ == '__main__': |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 506 | file = sys.argv[0] |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 507 | else: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 508 | file = __file__ |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 509 | testdir = os.path.dirname(file) or os.curdir |
| 510 | return testdir |
| 511 | |
Tim Peters | c5000df | 2002-06-02 21:42:01 +0000 | [diff] [blame] | 512 | def removepy(name): |
| 513 | if name.endswith(os.extsep + "py"): |
| 514 | name = name[:-3] |
| 515 | return name |
| 516 | |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 517 | def count(n, word): |
| 518 | if n == 1: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 519 | return "%d %s" % (n, word) |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 520 | else: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 521 | return "%d %ss" % (n, word) |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 522 | |
Tim Peters | a45da92 | 2001-08-12 03:45:50 +0000 | [diff] [blame] | 523 | def printlist(x, width=70, indent=4): |
Tim Peters | 7c7efe9 | 2002-08-23 17:55:54 +0000 | [diff] [blame] | 524 | """Print the elements of iterable x to stdout. |
Tim Peters | a45da92 | 2001-08-12 03:45:50 +0000 | [diff] [blame] | 525 | |
| 526 | Optional arg width (default 70) is the maximum line length. |
| 527 | Optional arg indent (default 4) is the number of blanks with which to |
| 528 | begin each line. |
| 529 | """ |
| 530 | |
Tim Peters | ba78bc4 | 2002-07-04 19:45:06 +0000 | [diff] [blame] | 531 | from textwrap import fill |
| 532 | blanks = ' ' * indent |
| 533 | print fill(' '.join(map(str, x)), width, |
| 534 | initial_indent=blanks, subsequent_indent=blanks) |
Tim Peters | a45da92 | 2001-08-12 03:45:50 +0000 | [diff] [blame] | 535 | |
Tim Peters | de14a30 | 2002-04-01 05:04:46 +0000 | [diff] [blame] | 536 | # Map sys.platform to a string containing the basenames of tests |
| 537 | # expected to be skipped on that platform. |
Tim Peters | 2a182db | 2002-10-09 01:07:11 +0000 | [diff] [blame] | 538 | # |
| 539 | # Special cases: |
| 540 | # test_pep277 |
| 541 | # The _ExpectedSkips constructor adds this to the set of expected |
| 542 | # skips if not os.path.supports_unicode_filenames. |
Tim Peters | 1b445d3 | 2002-11-24 18:53:11 +0000 | [diff] [blame] | 543 | # test_normalization |
| 544 | # Whether a skip is expected here depends on whether a large test |
| 545 | # input file has been downloaded. test_normalization.skip_expected |
Tim Peters | 1babdfc | 2002-11-24 19:19:09 +0000 | [diff] [blame] | 546 | # controls that. |
Tim Peters | b4ee4eb | 2002-12-04 03:26:57 +0000 | [diff] [blame] | 547 | # test_socket_ssl |
| 548 | # Controlled by test_socket_ssl.skip_expected. Requires the network |
| 549 | # resource, and a socket module with ssl support. |
Neal Norwitz | 55b61d2 | 2003-02-28 19:57:03 +0000 | [diff] [blame] | 550 | # test_timeout |
| 551 | # Controlled by test_timeout.skip_expected. Requires the network |
| 552 | # resource and a socket module. |
Tim Peters | de14a30 | 2002-04-01 05:04:46 +0000 | [diff] [blame] | 553 | |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 554 | _expectations = { |
| 555 | 'win32': |
| 556 | """ |
| 557 | test_al |
Skip Montanaro | 823ba28 | 2003-05-06 20:36:24 +0000 | [diff] [blame] | 558 | test_bsddb185 |
Tim Peters | 78e35f9 | 2002-11-22 20:00:34 +0000 | [diff] [blame] | 559 | test_bsddb3 |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 560 | test_cd |
| 561 | test_cl |
| 562 | test_commands |
| 563 | test_crypt |
Tim Peters | d703057 | 2001-10-22 22:06:08 +0000 | [diff] [blame] | 564 | test_curses |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 565 | test_dbm |
| 566 | test_dl |
Tim Peters | deb121a | 2002-04-11 19:52:58 +0000 | [diff] [blame] | 567 | test_email_codecs |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 568 | test_fcntl |
| 569 | test_fork1 |
| 570 | test_gdbm |
| 571 | test_gl |
| 572 | test_grp |
| 573 | test_imgfile |
Tim Peters | fd8e6e5 | 2003-03-04 00:26:38 +0000 | [diff] [blame] | 574 | test_ioctl |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 575 | test_largefile |
| 576 | test_linuxaudiodev |
| 577 | test_mhlib |
Tim Peters | de14a30 | 2002-04-01 05:04:46 +0000 | [diff] [blame] | 578 | test_mpz |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 579 | test_nis |
| 580 | test_openpty |
Tim Peters | efc4b12 | 2002-12-10 18:47:56 +0000 | [diff] [blame] | 581 | test_ossaudiodev |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 582 | test_poll |
Tim Peters | 003eb30 | 2003-02-17 21:48:48 +0000 | [diff] [blame] | 583 | test_posix |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 584 | test_pty |
| 585 | test_pwd |
Tim Peters | 1e33ffa | 2002-04-23 23:09:02 +0000 | [diff] [blame] | 586 | test_resource |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 587 | test_signal |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 588 | test_sunaudiodev |
| 589 | test_timing |
| 590 | """, |
| 591 | 'linux2': |
| 592 | """ |
| 593 | test_al |
Skip Montanaro | 823ba28 | 2003-05-06 20:36:24 +0000 | [diff] [blame] | 594 | test_bsddb185 |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 595 | test_cd |
| 596 | test_cl |
Guido van Rossum | f66dacd | 2001-10-23 15:10:55 +0000 | [diff] [blame] | 597 | test_curses |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 598 | test_dl |
Guido van Rossum | 6184c11 | 2002-04-16 02:14:04 +0000 | [diff] [blame] | 599 | test_email_codecs |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 600 | test_gl |
| 601 | test_imgfile |
| 602 | test_largefile |
Guido van Rossum | 4507ec7 | 2003-02-14 19:29:22 +0000 | [diff] [blame] | 603 | test_linuxaudiodev |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 604 | test_nis |
| 605 | test_ntpath |
Guido van Rossum | 4507ec7 | 2003-02-14 19:29:22 +0000 | [diff] [blame] | 606 | test_ossaudiodev |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 607 | test_sunaudiodev |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 608 | """, |
Jack Jansen | 49a806e | 2001-08-28 14:49:00 +0000 | [diff] [blame] | 609 | 'mac': |
Guido van Rossum | aa78236 | 2001-09-02 03:58:41 +0000 | [diff] [blame] | 610 | """ |
| 611 | test_al |
Jack Jansen | 6797514 | 2003-01-08 16:31:11 +0000 | [diff] [blame] | 612 | test_atexit |
Guido van Rossum | aa78236 | 2001-09-02 03:58:41 +0000 | [diff] [blame] | 613 | test_bsddb |
Skip Montanaro | 823ba28 | 2003-05-06 20:36:24 +0000 | [diff] [blame] | 614 | test_bsddb185 |
Jack Jansen | 6797514 | 2003-01-08 16:31:11 +0000 | [diff] [blame] | 615 | test_bsddb3 |
| 616 | test_bz2 |
Guido van Rossum | aa78236 | 2001-09-02 03:58:41 +0000 | [diff] [blame] | 617 | test_cd |
| 618 | test_cl |
| 619 | test_commands |
| 620 | test_crypt |
Jack Jansen | b3be216 | 2001-11-30 14:16:36 +0000 | [diff] [blame] | 621 | test_curses |
Guido van Rossum | aa78236 | 2001-09-02 03:58:41 +0000 | [diff] [blame] | 622 | test_dbm |
| 623 | test_dl |
Jack Jansen | 6797514 | 2003-01-08 16:31:11 +0000 | [diff] [blame] | 624 | test_email_codecs |
Guido van Rossum | aa78236 | 2001-09-02 03:58:41 +0000 | [diff] [blame] | 625 | test_fcntl |
| 626 | test_fork1 |
| 627 | test_gl |
| 628 | test_grp |
Jack Jansen | c4d6bdd | 2003-03-07 15:38:11 +0000 | [diff] [blame] | 629 | test_ioctl |
Guido van Rossum | aa78236 | 2001-09-02 03:58:41 +0000 | [diff] [blame] | 630 | test_imgfile |
| 631 | test_largefile |
| 632 | test_linuxaudiodev |
| 633 | test_locale |
| 634 | test_mmap |
Jack Jansen | 6797514 | 2003-01-08 16:31:11 +0000 | [diff] [blame] | 635 | test_mpz |
Guido van Rossum | aa78236 | 2001-09-02 03:58:41 +0000 | [diff] [blame] | 636 | test_nis |
| 637 | test_ntpath |
| 638 | test_openpty |
Jack Jansen | 6797514 | 2003-01-08 16:31:11 +0000 | [diff] [blame] | 639 | test_ossaudiodev |
Guido van Rossum | aa78236 | 2001-09-02 03:58:41 +0000 | [diff] [blame] | 640 | test_poll |
Jack Jansen | 6797514 | 2003-01-08 16:31:11 +0000 | [diff] [blame] | 641 | test_popen |
Guido van Rossum | aa78236 | 2001-09-02 03:58:41 +0000 | [diff] [blame] | 642 | test_popen2 |
Jack Jansen | 5bb97e6 | 2003-02-21 22:33:55 +0000 | [diff] [blame] | 643 | test_posix |
Guido van Rossum | aa78236 | 2001-09-02 03:58:41 +0000 | [diff] [blame] | 644 | test_pty |
| 645 | test_pwd |
Jack Jansen | 6797514 | 2003-01-08 16:31:11 +0000 | [diff] [blame] | 646 | test_resource |
Guido van Rossum | aa78236 | 2001-09-02 03:58:41 +0000 | [diff] [blame] | 647 | test_signal |
Guido van Rossum | aa78236 | 2001-09-02 03:58:41 +0000 | [diff] [blame] | 648 | test_sunaudiodev |
| 649 | test_sundry |
Jack Jansen | c4d6bdd | 2003-03-07 15:38:11 +0000 | [diff] [blame] | 650 | test_tarfile |
Guido van Rossum | aa78236 | 2001-09-02 03:58:41 +0000 | [diff] [blame] | 651 | test_timing |
Guido van Rossum | aa78236 | 2001-09-02 03:58:41 +0000 | [diff] [blame] | 652 | """, |
Martin v. Löwis | 21ee409 | 2002-09-30 16:19:48 +0000 | [diff] [blame] | 653 | 'unixware7': |
Martin v. Löwis | 0ace326 | 2001-09-05 14:38:48 +0000 | [diff] [blame] | 654 | """ |
| 655 | test_al |
| 656 | test_bsddb |
Skip Montanaro | 823ba28 | 2003-05-06 20:36:24 +0000 | [diff] [blame] | 657 | test_bsddb185 |
Martin v. Löwis | 0ace326 | 2001-09-05 14:38:48 +0000 | [diff] [blame] | 658 | test_cd |
| 659 | test_cl |
| 660 | test_dl |
| 661 | test_gl |
| 662 | test_imgfile |
| 663 | test_largefile |
| 664 | test_linuxaudiodev |
| 665 | test_minidom |
| 666 | test_nis |
| 667 | test_ntpath |
| 668 | test_openpty |
| 669 | test_pyexpat |
| 670 | test_sax |
Martin v. Löwis | 0ace326 | 2001-09-05 14:38:48 +0000 | [diff] [blame] | 671 | test_sunaudiodev |
| 672 | test_sundry |
Martin v. Löwis | 0ace326 | 2001-09-05 14:38:48 +0000 | [diff] [blame] | 673 | """, |
Martin v. Löwis | 21ee409 | 2002-09-30 16:19:48 +0000 | [diff] [blame] | 674 | 'openunix8': |
| 675 | """ |
| 676 | test_al |
| 677 | test_bsddb |
Skip Montanaro | 823ba28 | 2003-05-06 20:36:24 +0000 | [diff] [blame] | 678 | test_bsddb185 |
Martin v. Löwis | 21ee409 | 2002-09-30 16:19:48 +0000 | [diff] [blame] | 679 | test_cd |
| 680 | test_cl |
| 681 | test_dl |
| 682 | test_gl |
| 683 | test_imgfile |
| 684 | test_largefile |
| 685 | test_linuxaudiodev |
| 686 | test_minidom |
| 687 | test_nis |
| 688 | test_ntpath |
| 689 | test_openpty |
| 690 | test_pyexpat |
| 691 | test_sax |
Martin v. Löwis | 21ee409 | 2002-09-30 16:19:48 +0000 | [diff] [blame] | 692 | test_sunaudiodev |
| 693 | test_sundry |
Martin v. Löwis | 21ee409 | 2002-09-30 16:19:48 +0000 | [diff] [blame] | 694 | """, |
| 695 | 'sco_sv3': |
| 696 | """ |
| 697 | test_al |
| 698 | test_asynchat |
| 699 | test_bsddb |
Skip Montanaro | 823ba28 | 2003-05-06 20:36:24 +0000 | [diff] [blame] | 700 | test_bsddb185 |
Martin v. Löwis | 21ee409 | 2002-09-30 16:19:48 +0000 | [diff] [blame] | 701 | test_cd |
| 702 | test_cl |
| 703 | test_dl |
| 704 | test_fork1 |
| 705 | test_gettext |
| 706 | test_gl |
| 707 | test_imgfile |
| 708 | test_largefile |
| 709 | test_linuxaudiodev |
| 710 | test_locale |
| 711 | test_minidom |
| 712 | test_nis |
| 713 | test_ntpath |
| 714 | test_openpty |
| 715 | test_pyexpat |
| 716 | test_queue |
| 717 | test_sax |
Martin v. Löwis | 21ee409 | 2002-09-30 16:19:48 +0000 | [diff] [blame] | 718 | test_sunaudiodev |
| 719 | test_sundry |
| 720 | test_thread |
| 721 | test_threaded_import |
| 722 | test_threadedtempfile |
| 723 | test_threading |
Martin v. Löwis | 21ee409 | 2002-09-30 16:19:48 +0000 | [diff] [blame] | 724 | """, |
Guido van Rossum | e2ae77b | 2001-10-24 20:42:55 +0000 | [diff] [blame] | 725 | 'riscos': |
| 726 | """ |
| 727 | test_al |
| 728 | test_asynchat |
Martin v. Löwis | a94568a | 2003-05-10 07:36:56 +0000 | [diff] [blame] | 729 | test_atexit |
Guido van Rossum | e2ae77b | 2001-10-24 20:42:55 +0000 | [diff] [blame] | 730 | test_bsddb |
Skip Montanaro | 823ba28 | 2003-05-06 20:36:24 +0000 | [diff] [blame] | 731 | test_bsddb185 |
Martin v. Löwis | a94568a | 2003-05-10 07:36:56 +0000 | [diff] [blame] | 732 | test_bsddb3 |
Guido van Rossum | e2ae77b | 2001-10-24 20:42:55 +0000 | [diff] [blame] | 733 | test_cd |
| 734 | test_cl |
| 735 | test_commands |
| 736 | test_crypt |
| 737 | test_dbm |
| 738 | test_dl |
| 739 | test_fcntl |
| 740 | test_fork1 |
| 741 | test_gdbm |
| 742 | test_gl |
| 743 | test_grp |
| 744 | test_imgfile |
| 745 | test_largefile |
| 746 | test_linuxaudiodev |
| 747 | test_locale |
| 748 | test_mmap |
| 749 | test_nis |
| 750 | test_ntpath |
| 751 | test_openpty |
| 752 | test_poll |
| 753 | test_popen2 |
| 754 | test_pty |
| 755 | test_pwd |
Guido van Rossum | e2ae77b | 2001-10-24 20:42:55 +0000 | [diff] [blame] | 756 | test_strop |
| 757 | test_sunaudiodev |
| 758 | test_sundry |
| 759 | test_thread |
| 760 | test_threaded_import |
| 761 | test_threadedtempfile |
| 762 | test_threading |
| 763 | test_timing |
Guido van Rossum | e2ae77b | 2001-10-24 20:42:55 +0000 | [diff] [blame] | 764 | """, |
Jack Jansen | 8a97f4a | 2001-12-05 23:27:32 +0000 | [diff] [blame] | 765 | 'darwin': |
Jack Jansen | 398c236 | 2001-12-02 21:41:36 +0000 | [diff] [blame] | 766 | """ |
| 767 | test_al |
Jack Jansen | acda339 | 2002-12-30 23:03:13 +0000 | [diff] [blame] | 768 | test_bsddb |
Guido van Rossum | 9d42700 | 2002-12-03 10:24:56 +0000 | [diff] [blame] | 769 | test_bsddb3 |
Jack Jansen | 398c236 | 2001-12-02 21:41:36 +0000 | [diff] [blame] | 770 | test_cd |
| 771 | test_cl |
| 772 | test_curses |
| 773 | test_dl |
Guido van Rossum | 9d42700 | 2002-12-03 10:24:56 +0000 | [diff] [blame] | 774 | test_email_codecs |
Jack Jansen | 398c236 | 2001-12-02 21:41:36 +0000 | [diff] [blame] | 775 | test_gdbm |
| 776 | test_gl |
| 777 | test_imgfile |
| 778 | test_largefile |
| 779 | test_linuxaudiodev |
Jack Jansen | acda339 | 2002-12-30 23:03:13 +0000 | [diff] [blame] | 780 | test_locale |
Jack Jansen | 398c236 | 2001-12-02 21:41:36 +0000 | [diff] [blame] | 781 | test_minidom |
Guido van Rossum | 9d42700 | 2002-12-03 10:24:56 +0000 | [diff] [blame] | 782 | test_mpz |
Jack Jansen | 398c236 | 2001-12-02 21:41:36 +0000 | [diff] [blame] | 783 | test_nis |
| 784 | test_ntpath |
Jack Jansen | acda339 | 2002-12-30 23:03:13 +0000 | [diff] [blame] | 785 | test_ossaudiodev |
Jack Jansen | 398c236 | 2001-12-02 21:41:36 +0000 | [diff] [blame] | 786 | test_poll |
Jack Jansen | 398c236 | 2001-12-02 21:41:36 +0000 | [diff] [blame] | 787 | test_sunaudiodev |
Jack Jansen | 398c236 | 2001-12-02 21:41:36 +0000 | [diff] [blame] | 788 | """, |
Guido van Rossum | 11c3f09 | 2002-07-17 15:08:24 +0000 | [diff] [blame] | 789 | 'sunos5': |
| 790 | """ |
| 791 | test_al |
| 792 | test_bsddb |
Skip Montanaro | 823ba28 | 2003-05-06 20:36:24 +0000 | [diff] [blame] | 793 | test_bsddb185 |
Guido van Rossum | 11c3f09 | 2002-07-17 15:08:24 +0000 | [diff] [blame] | 794 | test_cd |
| 795 | test_cl |
| 796 | test_curses |
| 797 | test_dbm |
| 798 | test_email_codecs |
| 799 | test_gdbm |
| 800 | test_gl |
| 801 | test_gzip |
| 802 | test_imgfile |
| 803 | test_linuxaudiodev |
| 804 | test_mpz |
| 805 | test_openpty |
Guido van Rossum | 11c3f09 | 2002-07-17 15:08:24 +0000 | [diff] [blame] | 806 | test_zipfile |
| 807 | test_zlib |
Jeremy Hylton | ed375e1 | 2002-07-17 15:56:55 +0000 | [diff] [blame] | 808 | """, |
Skip Montanaro | b323021 | 2002-03-15 02:54:03 +0000 | [diff] [blame] | 809 | 'hp-ux11': |
| 810 | """ |
| 811 | test_al |
| 812 | test_bsddb |
Skip Montanaro | 823ba28 | 2003-05-06 20:36:24 +0000 | [diff] [blame] | 813 | test_bsddb185 |
Skip Montanaro | b323021 | 2002-03-15 02:54:03 +0000 | [diff] [blame] | 814 | test_cd |
| 815 | test_cl |
| 816 | test_curses |
| 817 | test_dl |
| 818 | test_gdbm |
| 819 | test_gl |
| 820 | test_gzip |
| 821 | test_imgfile |
| 822 | test_largefile |
| 823 | test_linuxaudiodev |
| 824 | test_locale |
| 825 | test_minidom |
| 826 | test_nis |
| 827 | test_ntpath |
| 828 | test_openpty |
| 829 | test_pyexpat |
| 830 | test_sax |
Skip Montanaro | b323021 | 2002-03-15 02:54:03 +0000 | [diff] [blame] | 831 | test_sunaudiodev |
Skip Montanaro | b323021 | 2002-03-15 02:54:03 +0000 | [diff] [blame] | 832 | test_zipfile |
| 833 | test_zlib |
| 834 | """, |
Martin v. Löwis | f90ae20 | 2002-06-11 06:22:31 +0000 | [diff] [blame] | 835 | 'atheos': |
Tim Peters | c411dba | 2002-07-16 21:35:23 +0000 | [diff] [blame] | 836 | """ |
| 837 | test_al |
Skip Montanaro | 823ba28 | 2003-05-06 20:36:24 +0000 | [diff] [blame] | 838 | test_bsddb185 |
Tim Peters | c411dba | 2002-07-16 21:35:23 +0000 | [diff] [blame] | 839 | test_cd |
| 840 | test_cl |
| 841 | test_curses |
| 842 | test_dl |
| 843 | test_email_codecs |
| 844 | test_gdbm |
| 845 | test_gl |
| 846 | test_imgfile |
| 847 | test_largefile |
| 848 | test_linuxaudiodev |
| 849 | test_locale |
| 850 | test_mhlib |
| 851 | test_mmap |
| 852 | test_mpz |
| 853 | test_nis |
| 854 | test_poll |
| 855 | test_popen2 |
| 856 | test_resource |
Tim Peters | c411dba | 2002-07-16 21:35:23 +0000 | [diff] [blame] | 857 | test_sunaudiodev |
Tim Peters | c411dba | 2002-07-16 21:35:23 +0000 | [diff] [blame] | 858 | """, |
Jason Tishler | 2511594 | 2002-12-05 15:18:15 +0000 | [diff] [blame] | 859 | 'cygwin': |
| 860 | """ |
| 861 | test_al |
Skip Montanaro | 823ba28 | 2003-05-06 20:36:24 +0000 | [diff] [blame] | 862 | test_bsddb185 |
Tim Peters | b0f89e0 | 2002-12-05 17:20:25 +0000 | [diff] [blame] | 863 | test_bsddb3 |
Jason Tishler | 2511594 | 2002-12-05 15:18:15 +0000 | [diff] [blame] | 864 | test_cd |
| 865 | test_cl |
| 866 | test_curses |
| 867 | test_dbm |
| 868 | test_email_codecs |
| 869 | test_gl |
| 870 | test_imgfile |
| 871 | test_largefile |
| 872 | test_linuxaudiodev |
| 873 | test_locale |
| 874 | test_mpz |
| 875 | test_nis |
Jason Tishler | 5c4ded2 | 2003-02-05 16:46:01 +0000 | [diff] [blame] | 876 | test_ossaudiodev |
Jason Tishler | 2511594 | 2002-12-05 15:18:15 +0000 | [diff] [blame] | 877 | test_socketserver |
| 878 | test_sunaudiodev |
Jason Tishler | 2511594 | 2002-12-05 15:18:15 +0000 | [diff] [blame] | 879 | """, |
Andrew MacIntyre | fd07e7d | 2002-12-31 11:26:50 +0000 | [diff] [blame] | 880 | 'os2emx': |
| 881 | """ |
| 882 | test_al |
| 883 | test_audioop |
Skip Montanaro | 823ba28 | 2003-05-06 20:36:24 +0000 | [diff] [blame] | 884 | test_bsddb185 |
Andrew MacIntyre | fd07e7d | 2002-12-31 11:26:50 +0000 | [diff] [blame] | 885 | test_bsddb3 |
| 886 | test_cd |
| 887 | test_cl |
| 888 | test_commands |
| 889 | test_curses |
| 890 | test_dl |
| 891 | test_email_codecs |
| 892 | test_gl |
| 893 | test_imgfile |
| 894 | test_largefile |
| 895 | test_linuxaudiodev |
| 896 | test_mhlib |
| 897 | test_mmap |
| 898 | test_nis |
| 899 | test_openpty |
| 900 | test_ossaudiodev |
| 901 | test_pty |
| 902 | test_resource |
| 903 | test_signal |
| 904 | test_sunaudiodev |
Andrew MacIntyre | fd07e7d | 2002-12-31 11:26:50 +0000 | [diff] [blame] | 905 | """, |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 906 | } |
| 907 | |
Tim Peters | b5b7b78 | 2001-08-12 01:20:39 +0000 | [diff] [blame] | 908 | class _ExpectedSkips: |
| 909 | def __init__(self): |
Tim Peters | 2a182db | 2002-10-09 01:07:11 +0000 | [diff] [blame] | 910 | import os.path |
Tim Peters | 1b445d3 | 2002-11-24 18:53:11 +0000 | [diff] [blame] | 911 | from test import test_normalization |
Tim Peters | b4ee4eb | 2002-12-04 03:26:57 +0000 | [diff] [blame] | 912 | from test import test_socket_ssl |
Neal Norwitz | 55b61d2 | 2003-02-28 19:57:03 +0000 | [diff] [blame] | 913 | from test import test_timeout |
Tim Peters | 1b445d3 | 2002-11-24 18:53:11 +0000 | [diff] [blame] | 914 | |
Tim Peters | 7c7efe9 | 2002-08-23 17:55:54 +0000 | [diff] [blame] | 915 | self.valid = False |
Tim Peters | de14a30 | 2002-04-01 05:04:46 +0000 | [diff] [blame] | 916 | if sys.platform in _expectations: |
Guido van Rossum | f73e30c | 2001-08-12 02:22:19 +0000 | [diff] [blame] | 917 | s = _expectations[sys.platform] |
Tim Peters | 7c7efe9 | 2002-08-23 17:55:54 +0000 | [diff] [blame] | 918 | self.expected = Set(s.split()) |
Tim Peters | 1b445d3 | 2002-11-24 18:53:11 +0000 | [diff] [blame] | 919 | |
Tim Peters | 2a182db | 2002-10-09 01:07:11 +0000 | [diff] [blame] | 920 | if not os.path.supports_unicode_filenames: |
| 921 | self.expected.add('test_pep277') |
Tim Peters | 1b445d3 | 2002-11-24 18:53:11 +0000 | [diff] [blame] | 922 | |
| 923 | if test_normalization.skip_expected: |
| 924 | self.expected.add('test_normalization') |
| 925 | |
Tim Peters | b4ee4eb | 2002-12-04 03:26:57 +0000 | [diff] [blame] | 926 | if test_socket_ssl.skip_expected: |
| 927 | self.expected.add('test_socket_ssl') |
| 928 | |
Neal Norwitz | 55b61d2 | 2003-02-28 19:57:03 +0000 | [diff] [blame] | 929 | if test_timeout.skip_expected: |
| 930 | self.expected.add('test_timeout') |
| 931 | |
Jack Jansen | 6afc5e0 | 2003-01-29 16:24:16 +0000 | [diff] [blame] | 932 | if not sys.platform in ("mac", "darwin"): |
Neal Norwitz | 7035c98 | 2003-03-29 22:01:17 +0000 | [diff] [blame] | 933 | MAC_ONLY = ["test_macostools", "test_macfs", "test_aepack", |
| 934 | "test_plistlib", "test_scriptpackages"] |
| 935 | for skip in MAC_ONLY: |
| 936 | self.expected.add(skip) |
Tim Peters | ecd79eb | 2003-01-29 00:35:32 +0000 | [diff] [blame] | 937 | |
| 938 | if sys.platform != "win32": |
Neal Norwitz | 7035c98 | 2003-03-29 22:01:17 +0000 | [diff] [blame] | 939 | WIN_ONLY = ["test_unicode_file", "test_winreg", |
| 940 | "test_winsound"] |
| 941 | for skip in WIN_ONLY: |
| 942 | self.expected.add(skip) |
Tim Peters | f2715e0 | 2003-02-19 02:35:07 +0000 | [diff] [blame] | 943 | |
Tim Peters | 7c7efe9 | 2002-08-23 17:55:54 +0000 | [diff] [blame] | 944 | self.valid = True |
Tim Peters | b5b7b78 | 2001-08-12 01:20:39 +0000 | [diff] [blame] | 945 | |
| 946 | def isvalid(self): |
| 947 | "Return true iff _ExpectedSkips knows about the current platform." |
| 948 | return self.valid |
| 949 | |
| 950 | def getexpected(self): |
| 951 | """Return set of test names we expect to skip on current platform. |
| 952 | |
| 953 | self.isvalid() must be true. |
| 954 | """ |
| 955 | |
| 956 | assert self.isvalid() |
| 957 | return self.expected |
| 958 | |
Guido van Rossum | 152494a | 1996-12-20 03:12:20 +0000 | [diff] [blame] | 959 | if __name__ == '__main__': |
Barry Warsaw | 408b6d3 | 2002-07-30 23:27:12 +0000 | [diff] [blame] | 960 | # Remove regrtest.py's own directory from the module search path. This |
| 961 | # prevents relative imports from working, and relative imports will screw |
| 962 | # up the testing framework. E.g. if both test.test_support and |
| 963 | # test_support are imported, they will not contain the same globals, and |
| 964 | # much of the testing framework relies on the globals in the |
| 965 | # test.test_support module. |
| 966 | mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0]))) |
| 967 | i = pathlen = len(sys.path) |
| 968 | while i >= 0: |
| 969 | i -= 1 |
| 970 | if os.path.abspath(os.path.normpath(sys.path[i])) == mydir: |
| 971 | del sys.path[i] |
| 972 | if len(sys.path) == pathlen: |
| 973 | print 'Could not find %r in sys.path to remove it' % mydir |
Barry Warsaw | 08fca52 | 2001-08-20 22:33:46 +0000 | [diff] [blame] | 974 | main() |