blob: c8c916760cae2abd4b74c37d2c9d05a2865f589d [file] [log] [blame]
Guido van Rossum152494a1996-12-20 03:12:20 +00001#! /usr/bin/env python
2
3"""Regression test.
4
5This will find all modules whose name is "test_*" in the test
6directory, and run them. Various command line options provide
7additional facilities.
8
9Command line options:
10
Barry Warsawa873b032000-08-03 15:50:37 +000011-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
Neil Schemenauer8a00abc2000-10-13 01:32:42 +000017-l: findleaks -- if GC is available detect tests that leak memory
Barry Warsaw08fca522001-08-20 22:33:46 +000018-u: use -- specify which special resource intensive tests to run
19-h: help -- print this text and exit
Guido van Rossum152494a1996-12-20 03:12:20 +000020
21If non-option arguments are present, they are names for tests to run,
22unless -x is given, in which case they are names for tests not to run.
23If no test names are given, all tests are run.
Guido van Rossumf58ed251997-03-07 21:04:33 +000024
Guido van Rossuma4122201997-08-18 20:08:24 +000025-v is incompatible with -g and does not compare test output files.
Barry Warsawe11e3de1999-01-28 19:51:51 +000026
Barry Warsaw22e41822001-02-23 18:31:40 +000027-s means to run only a single test and exit. This is useful when doing memory
28analysis on the Python interpreter (which tend to consume to many resources to
29run the full regression test non-stop). The file /tmp/pynexttest is read to
30find the next test to run. If this file is missing, the first test_*.py file
31in testdir or on the command line is used. (actually tempfile.gettempdir() is
32used instead of /tmp).
Barry Warsawe11e3de1999-01-28 19:51:51 +000033
Barry Warsaw08fca522001-08-20 22:33:46 +000034-u is used to specify which special resource intensive tests to run, such as
35those requiring large file support or network connectivity. The argument is a
36comma-separated list of words indicating the resources to test. Currently
37only the following are defined:
38
39 largefile - It is okay to run some test that may create huge files. These
40 tests can take a long time and may consume >2GB of disk space
41 temporarily.
42
43 network - It is okay to run tests that use external network resource,
44 e.g. testing SSL support for sockets.
Guido van Rossum152494a1996-12-20 03:12:20 +000045"""
46
47import sys
Guido van Rossum152494a1996-12-20 03:12:20 +000048import os
49import getopt
Guido van Rossum9e48b271997-07-16 01:56:13 +000050import traceback
Skip Montanaroab1c7912000-06-30 16:39:27 +000051import random
Fred Drakeae1bb172001-05-21 21:08:12 +000052import StringIO
Guido van Rossum152494a1996-12-20 03:12:20 +000053
54import test_support
55
Barry Warsaw08fca522001-08-20 22:33:46 +000056def usage(code, msg=''):
57 print __doc__
58 if msg: print msg
59 sys.exit(code)
60
61
Skip Montanaroab1c7912000-06-30 16:39:27 +000062def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
Neil Schemenauerd569f232000-09-22 15:29:28 +000063 exclude=0, single=0, randomize=0, findleaks=0,
Barry Warsaw08fca522001-08-20 22:33:46 +000064 use_resources=None):
Guido van Rossum6fd83b71998-08-01 17:04:08 +000065 """Execute a test suite.
66
Thomas Wouters7e474022000-07-16 12:04:32 +000067 This also parses command-line options and modifies its behavior
Fred Drake004d5e62000-10-23 17:22:08 +000068 accordingly.
Guido van Rossum6fd83b71998-08-01 17:04:08 +000069
70 tests -- a list of strings containing test names (optional)
71 testdir -- the directory in which to look for tests (optional)
72
73 Users other than the Python test suite will certainly want to
74 specify testdir; if it's omitted, the directory containing the
Fred Drake004d5e62000-10-23 17:22:08 +000075 Python test suite is searched for.
Guido van Rossum6fd83b71998-08-01 17:04:08 +000076
77 If the tests argument is omitted, the tests listed on the
78 command-line will be used. If that's empty, too, then all *.py
79 files beginning with test_ will be used.
Skip Montanaroab1c7912000-06-30 16:39:27 +000080
Barry Warsaw08fca522001-08-20 22:33:46 +000081 The other default arguments (verbose, quiet, generate, exclude, single,
82 randomize, findleaks, and use_resources) allow programmers calling main()
Barry Warsawa873b032000-08-03 15:50:37 +000083 directly to set the values that would normally be set by flags on the
84 command line.
85
Guido van Rossum6fd83b71998-08-01 17:04:08 +000086 """
Fred Drake004d5e62000-10-23 17:22:08 +000087
Guido van Rossum152494a1996-12-20 03:12:20 +000088 try:
Barry Warsaw08fca522001-08-20 22:33:46 +000089 opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrlu:',
90 ['help', 'verbose', 'quiet', 'generate',
91 'exclude', 'single', 'random',
92 'findleaks', 'use='])
Guido van Rossum152494a1996-12-20 03:12:20 +000093 except getopt.error, msg:
Barry Warsaw08fca522001-08-20 22:33:46 +000094 usage(2, msg)
95
96 # Defaults
97 if use_resources is None:
98 use_resources = []
Guido van Rossum152494a1996-12-20 03:12:20 +000099 for o, a in opts:
Barry Warsaw08fca522001-08-20 22:33:46 +0000100 if o in ('-h', '--help'):
101 usage(0)
102 elif o in ('-v', '--verbose'):
103 verbose += 1
104 elif o in ('-q', '--quiet'):
105 quiet = 1;
106 verbose = 0
107 elif o in ('-g', '--generate'):
108 generate = 1
109 elif o in ('-x', '--exclude'):
110 exclude = 1
111 elif o in ('-s', '--single'):
112 single = 1
113 elif o in ('-r', '--randomize'):
114 randomize = 1
115 elif o in ('-l', '--findleaks'):
116 findleaks = 1
117 elif o in ('-u', '--use'):
Guido van Rossumfe3f6962001-09-06 16:09:41 +0000118 u = [x.lower() for x in a.split(',')]
119 for r in u:
Barry Warsaw08fca522001-08-20 22:33:46 +0000120 if r not in ('largefile', 'network'):
121 usage(1, 'Invalid -u/--use option: %s' % a)
Guido van Rossumfe3f6962001-09-06 16:09:41 +0000122 use_resources.extend(u)
Guido van Rossuma4122201997-08-18 20:08:24 +0000123 if generate and verbose:
Barry Warsaw08fca522001-08-20 22:33:46 +0000124 usage(2, "-g and -v don't go together!")
125
Guido van Rossum152494a1996-12-20 03:12:20 +0000126 good = []
127 bad = []
128 skipped = []
Barry Warsawe11e3de1999-01-28 19:51:51 +0000129
Neil Schemenauerd569f232000-09-22 15:29:28 +0000130 if findleaks:
Barry Warsawa873b032000-08-03 15:50:37 +0000131 try:
132 import gc
133 except ImportError:
Neil Schemenauer8a00abc2000-10-13 01:32:42 +0000134 print 'No GC available, disabling findleaks.'
Neil Schemenauerd569f232000-09-22 15:29:28 +0000135 findleaks = 0
Barry Warsawa873b032000-08-03 15:50:37 +0000136 else:
Neil Schemenauer8a00abc2000-10-13 01:32:42 +0000137 # Uncomment the line below to report garbage that is not
138 # freeable by reference counting alone. By default only
139 # garbage that is not collectable by the GC is reported.
140 #gc.set_debug(gc.DEBUG_SAVEALL)
Neil Schemenauerd569f232000-09-22 15:29:28 +0000141 found_garbage = []
Barry Warsawa873b032000-08-03 15:50:37 +0000142
Barry Warsawe11e3de1999-01-28 19:51:51 +0000143 if single:
144 from tempfile import gettempdir
145 filename = os.path.join(gettempdir(), 'pynexttest')
146 try:
147 fp = open(filename, 'r')
Eric S. Raymondfc170b12001-02-09 11:51:27 +0000148 next = fp.read().strip()
Barry Warsawe11e3de1999-01-28 19:51:51 +0000149 tests = [next]
150 fp.close()
151 except IOError:
152 pass
Guido van Rossuma4122201997-08-18 20:08:24 +0000153 for i in range(len(args)):
Guido van Rossum41360a41998-03-26 19:42:58 +0000154 # Strip trailing ".py" from arguments
155 if args[i][-3:] == '.py':
156 args[i] = args[i][:-3]
Guido van Rossum6c74fea1998-08-25 12:29:08 +0000157 stdtests = STDTESTS[:]
158 nottests = NOTTESTS[:]
Guido van Rossum152494a1996-12-20 03:12:20 +0000159 if exclude:
Guido van Rossum6c74fea1998-08-25 12:29:08 +0000160 for arg in args:
161 if arg in stdtests:
162 stdtests.remove(arg)
163 nottests[:0] = args
Guido van Rossum41360a41998-03-26 19:42:58 +0000164 args = []
Guido van Rossum747e1ca1998-08-24 13:48:36 +0000165 tests = tests or args or findtests(testdir, stdtests, nottests)
Barry Warsawe11e3de1999-01-28 19:51:51 +0000166 if single:
167 tests = tests[:1]
Skip Montanaroab1c7912000-06-30 16:39:27 +0000168 if randomize:
169 random.shuffle(tests)
Guido van Rossum41360a41998-03-26 19:42:58 +0000170 test_support.verbose = verbose # Tell tests to be moderately quiet
Barry Warsaw08fca522001-08-20 22:33:46 +0000171 test_support.use_resources = use_resources
Guido van Rossum5796d262000-04-21 21:35:06 +0000172 save_modules = sys.modules.keys()
Guido van Rossum152494a1996-12-20 03:12:20 +0000173 for test in tests:
Guido van Rossum41360a41998-03-26 19:42:58 +0000174 if not quiet:
175 print test
Trent Mickf29f47b2000-08-11 19:02:59 +0000176 ok = runtest(test, generate, verbose, quiet, testdir)
Guido van Rossum41360a41998-03-26 19:42:58 +0000177 if ok > 0:
178 good.append(test)
179 elif ok == 0:
180 bad.append(test)
181 else:
Guido van Rossum41360a41998-03-26 19:42:58 +0000182 skipped.append(test)
Neil Schemenauerd569f232000-09-22 15:29:28 +0000183 if findleaks:
184 gc.collect()
185 if gc.garbage:
Neil Schemenauer8a00abc2000-10-13 01:32:42 +0000186 print "Warning: test created", len(gc.garbage),
187 print "uncollectable object(s)."
188 # move the uncollectable objects somewhere so we don't see
189 # them again
Neil Schemenauerd569f232000-09-22 15:29:28 +0000190 found_garbage.extend(gc.garbage)
191 del gc.garbage[:]
Guido van Rossum5796d262000-04-21 21:35:06 +0000192 # Unload the newly imported modules (best effort finalization)
193 for module in sys.modules.keys():
Guido van Rossum51931142000-05-05 14:27:39 +0000194 if module not in save_modules and module.startswith("test."):
Guido van Rossum5796d262000-04-21 21:35:06 +0000195 test_support.unload(module)
Guido van Rossum152494a1996-12-20 03:12:20 +0000196 if good and not quiet:
Guido van Rossum41360a41998-03-26 19:42:58 +0000197 if not bad and not skipped and len(good) > 1:
198 print "All",
199 print count(len(good), "test"), "OK."
Tim Peters1a4d77b2000-12-30 22:21:22 +0000200 if verbose:
201 print "CAUTION: stdout isn't compared in verbose mode: a test"
202 print "that passes in verbose mode may fail without it."
Guido van Rossum152494a1996-12-20 03:12:20 +0000203 if bad:
Tim Petersa45da922001-08-12 03:45:50 +0000204 print count(len(bad), "test"), "failed:"
205 printlist(bad)
Guido van Rossum152494a1996-12-20 03:12:20 +0000206 if skipped and not quiet:
Tim Petersa45da922001-08-12 03:45:50 +0000207 print count(len(skipped), "test"), "skipped:"
208 printlist(skipped)
Barry Warsawe11e3de1999-01-28 19:51:51 +0000209
Tim Petersb5b7b782001-08-12 01:20:39 +0000210 e = _ExpectedSkips()
Tim Petersa2be2d62001-08-12 02:01:09 +0000211 plat = sys.platform
Tim Petersb5b7b782001-08-12 01:20:39 +0000212 if e.isvalid():
213 surprise = _Set(skipped) - e.getexpected()
Tim Petersb5b7b782001-08-12 01:20:39 +0000214 if surprise:
215 print count(len(surprise), "skip"), \
Tim Petersa45da922001-08-12 03:45:50 +0000216 "unexpected on", plat + ":"
217 printlist(surprise)
Tim Petersb5b7b782001-08-12 01:20:39 +0000218 else:
219 print "Those skips are all expected on", plat + "."
220 else:
221 print "Ask someone to teach regrtest.py about which tests are"
222 print "expected to get skipped on", plat + "."
223
Barry Warsawe11e3de1999-01-28 19:51:51 +0000224 if single:
225 alltests = findtests(testdir, stdtests, nottests)
226 for i in range(len(alltests)):
227 if tests[0] == alltests[i]:
228 if i == len(alltests) - 1:
229 os.unlink(filename)
230 else:
231 fp = open(filename, 'w')
232 fp.write(alltests[i+1] + '\n')
233 fp.close()
234 break
235 else:
236 os.unlink(filename)
237
Barry Warsaw08fca522001-08-20 22:33:46 +0000238 sys.exit(len(bad) > 0)
239
Guido van Rossum152494a1996-12-20 03:12:20 +0000240
Guido van Rossum6fd83b71998-08-01 17:04:08 +0000241STDTESTS = [
Guido van Rossum152494a1996-12-20 03:12:20 +0000242 'test_grammar',
243 'test_opcodes',
244 'test_operations',
245 'test_builtin',
246 'test_exceptions',
247 'test_types',
248 ]
249
Guido van Rossum6fd83b71998-08-01 17:04:08 +0000250NOTTESTS = [
Guido van Rossum152494a1996-12-20 03:12:20 +0000251 'test_support',
252 'test_b1',
253 'test_b2',
Jeremy Hylton62e2c7e2001-02-28 17:48:06 +0000254 'test_future1',
255 'test_future2',
Jeremy Hylton8471a352001-08-20 20:33:42 +0000256 'test_future3',
Guido van Rossum152494a1996-12-20 03:12:20 +0000257 ]
258
Guido van Rossum6fd83b71998-08-01 17:04:08 +0000259def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
Guido van Rossum152494a1996-12-20 03:12:20 +0000260 """Return a list of all applicable test modules."""
Guido van Rossum6fd83b71998-08-01 17:04:08 +0000261 if not testdir: testdir = findtestdir()
Guido van Rossum152494a1996-12-20 03:12:20 +0000262 names = os.listdir(testdir)
263 tests = []
264 for name in names:
Guido van Rossum41360a41998-03-26 19:42:58 +0000265 if name[:5] == "test_" and name[-3:] == ".py":
266 modname = name[:-3]
267 if modname not in stdtests and modname not in nottests:
268 tests.append(modname)
Guido van Rossum152494a1996-12-20 03:12:20 +0000269 tests.sort()
270 return stdtests + tests
271
Trent Mickf29f47b2000-08-11 19:02:59 +0000272def runtest(test, generate, verbose, quiet, testdir = None):
Guido van Rossum6fd83b71998-08-01 17:04:08 +0000273 """Run a single test.
274 test -- the name of the test
275 generate -- if true, generate output, instead of running the test
276 and comparing it to a previously created output file
277 verbose -- if true, print more messages
Trent Mickf29f47b2000-08-11 19:02:59 +0000278 quiet -- if true, don't print 'skipped' messages (probably redundant)
Guido van Rossum6fd83b71998-08-01 17:04:08 +0000279 testdir -- test directory
280 """
Guido van Rossum152494a1996-12-20 03:12:20 +0000281 test_support.unload(test)
Guido van Rossum6fd83b71998-08-01 17:04:08 +0000282 if not testdir: testdir = findtestdir()
Guido van Rossum152494a1996-12-20 03:12:20 +0000283 outputdir = os.path.join(testdir, "output")
284 outputfile = os.path.join(outputdir, test)
Guido van Rossum0fcca4e2001-09-21 20:31:52 +0000285 if verbose or generate:
Guido van Rossum41360a41998-03-26 19:42:58 +0000286 cfp = None
Guido van Rossum0fcca4e2001-09-21 20:31:52 +0000287 else:
288 cfp = StringIO.StringIO()
Guido van Rossum152494a1996-12-20 03:12:20 +0000289 try:
Guido van Rossum0a076392001-09-21 20:45:44 +0000290 sys.save_stdout = sys.stdout
Guido van Rossum41360a41998-03-26 19:42:58 +0000291 try:
292 if cfp:
293 sys.stdout = cfp
294 print test # Output file starts with test name
Tim Petersd9742212001-05-22 18:28:25 +0000295 the_module = __import__(test, globals(), locals(), [])
296 # Most tests run to completion simply as a side-effect of
297 # being imported. For the benefit of tests that can't run
298 # that way (like test_threaded_import), explicitly invoke
299 # their test_main() function (if it exists).
300 indirect_test = getattr(the_module, "test_main", None)
301 if indirect_test is not None:
302 indirect_test()
Guido van Rossum41360a41998-03-26 19:42:58 +0000303 finally:
Guido van Rossum0a076392001-09-21 20:45:44 +0000304 sys.stdout = sys.save_stdout
Thomas Wouters3af826e2000-08-04 13:17:51 +0000305 except (ImportError, test_support.TestSkipped), msg:
Trent Mickf29f47b2000-08-11 19:02:59 +0000306 if not quiet:
Guido van Rossumeb949052001-09-18 20:34:19 +0000307 print "test", test, "skipped --", msg
Guido van Rossum41360a41998-03-26 19:42:58 +0000308 return -1
Fred Drakefe5c22a2000-08-18 16:04:05 +0000309 except KeyboardInterrupt:
310 raise
Guido van Rossum152494a1996-12-20 03:12:20 +0000311 except test_support.TestFailed, msg:
Guido van Rossum41360a41998-03-26 19:42:58 +0000312 print "test", test, "failed --", msg
313 return 0
Guido van Rossum9e48b271997-07-16 01:56:13 +0000314 except:
Guido van Rossum41360a41998-03-26 19:42:58 +0000315 type, value = sys.exc_info()[:2]
Fred Drake27c4b392000-08-23 20:34:40 +0000316 print "test", test, "crashed --", str(type) + ":", value
Guido van Rossum41360a41998-03-26 19:42:58 +0000317 if verbose:
318 traceback.print_exc(file=sys.stdout)
319 return 0
Guido van Rossum152494a1996-12-20 03:12:20 +0000320 else:
Guido van Rossum0fcca4e2001-09-21 20:31:52 +0000321 if not cfp:
322 return 1
323 output = cfp.getvalue()
Fred Drakee51fe8d2001-05-29 17:10:51 +0000324 if generate:
Fred Drakee51fe8d2001-05-29 17:10:51 +0000325 if output == test + "\n":
326 if os.path.exists(outputfile):
327 # Write it since it already exists (and the contents
328 # may have changed), but let the user know it isn't
329 # needed:
Fred Drakee51fe8d2001-05-29 17:10:51 +0000330 print "output file", outputfile, \
331 "is no longer needed; consider removing it"
Guido van Rossum0fcca4e2001-09-21 20:31:52 +0000332 else:
333 # We don't need it, so don't create it.
334 return 1
335 fp = open(outputfile, "w")
336 fp.write(output)
337 fp.close()
338 return 1
339 if os.path.exists(outputfile):
340 fp = open(outputfile, "r")
341 expected = fp.read()
342 fp.close()
343 else:
344 expected = test + "\n"
345 if output == expected:
346 return 1
347 print "test", test, "produced unexpected output:"
348 reportdiff(expected, output)
349 return 0
350
351def reportdiff(expected, output):
352 print "*" * 70
353 import difflib
354 a = expected.splitlines(1)
355 b = output.splitlines(1)
356 diff = difflib.ndiff(a, b)
357 print ''.join(diff),
358 print "*" * 70
Guido van Rossum152494a1996-12-20 03:12:20 +0000359
360def findtestdir():
361 if __name__ == '__main__':
Guido van Rossum41360a41998-03-26 19:42:58 +0000362 file = sys.argv[0]
Guido van Rossum152494a1996-12-20 03:12:20 +0000363 else:
Guido van Rossum41360a41998-03-26 19:42:58 +0000364 file = __file__
Guido van Rossum152494a1996-12-20 03:12:20 +0000365 testdir = os.path.dirname(file) or os.curdir
366 return testdir
367
368def count(n, word):
369 if n == 1:
Guido van Rossum41360a41998-03-26 19:42:58 +0000370 return "%d %s" % (n, word)
Guido van Rossum152494a1996-12-20 03:12:20 +0000371 else:
Guido van Rossum41360a41998-03-26 19:42:58 +0000372 return "%d %ss" % (n, word)
Guido van Rossum152494a1996-12-20 03:12:20 +0000373
Tim Petersa45da922001-08-12 03:45:50 +0000374def printlist(x, width=70, indent=4):
375 """Print the elements of a sequence to stdout.
376
377 Optional arg width (default 70) is the maximum line length.
378 Optional arg indent (default 4) is the number of blanks with which to
379 begin each line.
380 """
381
382 line = ' ' * indent
383 for one in map(str, x):
384 w = len(line) + len(one)
385 if line[-1:] == ' ':
386 pad = ''
387 else:
388 pad = ' '
389 w += 1
390 if w > width:
391 print line
392 line = ' ' * indent + one
393 else:
394 line += pad + one
395 if len(line) > indent:
396 print line
397
Tim Petersb5b7b782001-08-12 01:20:39 +0000398class _Set:
399 def __init__(self, seq=[]):
400 data = self.data = {}
401 for x in seq:
402 data[x] = 1
403
404 def __len__(self):
405 return len(self.data)
406
407 def __sub__(self, other):
408 "Return set of all elements in self not in other."
409 result = _Set()
410 data = result.data = self.data.copy()
411 for x in other.data:
412 if x in data:
413 del data[x]
414 return result
415
Jeremy Hylton39f77bc2001-08-12 21:53:08 +0000416 def __iter__(self):
417 return iter(self.data)
418
Tim Petersb5b7b782001-08-12 01:20:39 +0000419 def tolist(self, sorted=1):
420 "Return _Set elements as a list."
421 data = self.data.keys()
422 if sorted:
423 data.sort()
424 return data
425
Guido van Rossumf73e30c2001-08-12 02:22:19 +0000426_expectations = {
427 'win32':
428 """
429 test_al
430 test_cd
431 test_cl
432 test_commands
433 test_crypt
434 test_dbm
435 test_dl
436 test_fcntl
437 test_fork1
438 test_gdbm
439 test_gl
440 test_grp
441 test_imgfile
442 test_largefile
443 test_linuxaudiodev
444 test_mhlib
445 test_nis
446 test_openpty
447 test_poll
448 test_pty
449 test_pwd
450 test_signal
Barry Warsaw08fca522001-08-20 22:33:46 +0000451 test_socket_ssl
Tim Petersa86f0c12001-09-18 02:18:57 +0000452 test_socketserver
Guido van Rossumf73e30c2001-08-12 02:22:19 +0000453 test_sunaudiodev
454 test_timing
455 """,
456 'linux2':
457 """
458 test_al
459 test_cd
460 test_cl
461 test_dl
462 test_gl
463 test_imgfile
464 test_largefile
465 test_nis
466 test_ntpath
Barry Warsaw08fca522001-08-20 22:33:46 +0000467 test_socket_ssl
Guido van Rossumf73e30c2001-08-12 02:22:19 +0000468 test_socketserver
469 test_sunaudiodev
470 test_unicode_file
471 test_winreg
472 test_winsound
473 """,
Jack Jansen49a806e2001-08-28 14:49:00 +0000474 'mac':
Guido van Rossumaa782362001-09-02 03:58:41 +0000475 """
476 test_al
477 test_bsddb
478 test_cd
479 test_cl
480 test_commands
481 test_crypt
482 test_dbm
483 test_dl
484 test_fcntl
485 test_fork1
486 test_gl
487 test_grp
488 test_imgfile
489 test_largefile
490 test_linuxaudiodev
491 test_locale
492 test_mmap
493 test_nis
494 test_ntpath
495 test_openpty
496 test_poll
497 test_popen2
498 test_pty
499 test_pwd
500 test_signal
501 test_socket_ssl
502 test_socketserver
503 test_sunaudiodev
504 test_sundry
505 test_timing
506 test_unicode_file
507 test_winreg
508 test_winsound
509 """,
Martin v. Löwis0ace3262001-09-05 14:38:48 +0000510 'unixware5':
511 """
512 test_al
513 test_bsddb
514 test_cd
515 test_cl
516 test_dl
517 test_gl
518 test_imgfile
519 test_largefile
520 test_linuxaudiodev
521 test_minidom
522 test_nis
523 test_ntpath
524 test_openpty
525 test_pyexpat
526 test_sax
527 test_socketserver
528 test_sunaudiodev
529 test_sundry
530 test_unicode_file
531 test_winreg
532 test_winsound
533 """,
Guido van Rossumf73e30c2001-08-12 02:22:19 +0000534}
535
Tim Petersb5b7b782001-08-12 01:20:39 +0000536class _ExpectedSkips:
537 def __init__(self):
538 self.valid = 0
Guido van Rossumf73e30c2001-08-12 02:22:19 +0000539 if _expectations.has_key(sys.platform):
540 s = _expectations[sys.platform]
Tim Petersb5b7b782001-08-12 01:20:39 +0000541 self.expected = _Set(s.split())
Guido van Rossumf73e30c2001-08-12 02:22:19 +0000542 self.valid = 1
Tim Petersb5b7b782001-08-12 01:20:39 +0000543
544 def isvalid(self):
545 "Return true iff _ExpectedSkips knows about the current platform."
546 return self.valid
547
548 def getexpected(self):
549 """Return set of test names we expect to skip on current platform.
550
551 self.isvalid() must be true.
552 """
553
554 assert self.isvalid()
555 return self.expected
556
Guido van Rossum152494a1996-12-20 03:12:20 +0000557if __name__ == '__main__':
Barry Warsaw08fca522001-08-20 22:33:46 +0000558 main()