blob: 6a4b7fdd493a7e8d5a912202d933935c4289c3d4 [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
Trent Mickf29f47b2000-08-11 19:02:59 +000018--have-resources -- run tests that require large resources (time/space)
Guido van Rossum152494a1996-12-20 03:12:20 +000019
20If non-option arguments are present, they are names for tests to run,
21unless -x is given, in which case they are names for tests not to run.
22If no test names are given, all tests are run.
Guido van Rossumf58ed251997-03-07 21:04:33 +000023
Guido van Rossuma4122201997-08-18 20:08:24 +000024-v is incompatible with -g and does not compare test output files.
Barry Warsawe11e3de1999-01-28 19:51:51 +000025
Barry Warsaw22e41822001-02-23 18:31:40 +000026-s means to run only a single test and exit. This is useful when doing memory
27analysis on the Python interpreter (which tend to consume to many resources to
28run the full regression test non-stop). The file /tmp/pynexttest is read to
29find the next test to run. If this file is missing, the first test_*.py file
30in testdir or on the command line is used. (actually tempfile.gettempdir() is
31used instead of /tmp).
Barry Warsawe11e3de1999-01-28 19:51:51 +000032
Guido van Rossum152494a1996-12-20 03:12:20 +000033"""
34
35import sys
Guido van Rossum152494a1996-12-20 03:12:20 +000036import os
37import getopt
Guido van Rossum9e48b271997-07-16 01:56:13 +000038import traceback
Skip Montanaroab1c7912000-06-30 16:39:27 +000039import random
Fred Drakeae1bb172001-05-21 21:08:12 +000040import StringIO
Guido van Rossum152494a1996-12-20 03:12:20 +000041
42import test_support
43
Skip Montanaroab1c7912000-06-30 16:39:27 +000044def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
Neil Schemenauerd569f232000-09-22 15:29:28 +000045 exclude=0, single=0, randomize=0, findleaks=0,
Trent Mickf29f47b2000-08-11 19:02:59 +000046 use_large_resources=0):
Guido van Rossum6fd83b71998-08-01 17:04:08 +000047 """Execute a test suite.
48
Thomas Wouters7e474022000-07-16 12:04:32 +000049 This also parses command-line options and modifies its behavior
Fred Drake004d5e62000-10-23 17:22:08 +000050 accordingly.
Guido van Rossum6fd83b71998-08-01 17:04:08 +000051
52 tests -- a list of strings containing test names (optional)
53 testdir -- the directory in which to look for tests (optional)
54
55 Users other than the Python test suite will certainly want to
56 specify testdir; if it's omitted, the directory containing the
Fred Drake004d5e62000-10-23 17:22:08 +000057 Python test suite is searched for.
Guido van Rossum6fd83b71998-08-01 17:04:08 +000058
59 If the tests argument is omitted, the tests listed on the
60 command-line will be used. If that's empty, too, then all *.py
61 files beginning with test_ will be used.
Skip Montanaroab1c7912000-06-30 16:39:27 +000062
Barry Warsawa873b032000-08-03 15:50:37 +000063 The other seven default arguments (verbose, quiet, generate, exclude,
Neil Schemenauerd569f232000-09-22 15:29:28 +000064 single, randomize, and findleaks) allow programmers calling main()
Barry Warsawa873b032000-08-03 15:50:37 +000065 directly to set the values that would normally be set by flags on the
66 command line.
67
Guido van Rossum6fd83b71998-08-01 17:04:08 +000068 """
Fred Drake004d5e62000-10-23 17:22:08 +000069
Guido van Rossum152494a1996-12-20 03:12:20 +000070 try:
Trent Mickf29f47b2000-08-11 19:02:59 +000071 opts, args = getopt.getopt(sys.argv[1:], 'vgqxsrl', ['have-resources'])
Guido van Rossum152494a1996-12-20 03:12:20 +000072 except getopt.error, msg:
Guido van Rossum41360a41998-03-26 19:42:58 +000073 print msg
74 print __doc__
75 return 2
Guido van Rossum152494a1996-12-20 03:12:20 +000076 for o, a in opts:
Guido van Rossum41360a41998-03-26 19:42:58 +000077 if o == '-v': verbose = verbose+1
78 if o == '-q': quiet = 1; verbose = 0
79 if o == '-g': generate = 1
80 if o == '-x': exclude = 1
Barry Warsawe11e3de1999-01-28 19:51:51 +000081 if o == '-s': single = 1
Skip Montanaroab1c7912000-06-30 16:39:27 +000082 if o == '-r': randomize = 1
Neil Schemenauerd569f232000-09-22 15:29:28 +000083 if o == '-l': findleaks = 1
Trent Mickf29f47b2000-08-11 19:02:59 +000084 if o == '--have-resources': use_large_resources = 1
Guido van Rossuma4122201997-08-18 20:08:24 +000085 if generate and verbose:
Guido van Rossum41360a41998-03-26 19:42:58 +000086 print "-g and -v don't go together!"
87 return 2
Guido van Rossum152494a1996-12-20 03:12:20 +000088 good = []
89 bad = []
90 skipped = []
Barry Warsawe11e3de1999-01-28 19:51:51 +000091
Neil Schemenauerd569f232000-09-22 15:29:28 +000092 if findleaks:
Barry Warsawa873b032000-08-03 15:50:37 +000093 try:
94 import gc
95 except ImportError:
Neil Schemenauer8a00abc2000-10-13 01:32:42 +000096 print 'No GC available, disabling findleaks.'
Neil Schemenauerd569f232000-09-22 15:29:28 +000097 findleaks = 0
Barry Warsawa873b032000-08-03 15:50:37 +000098 else:
Neil Schemenauer8a00abc2000-10-13 01:32:42 +000099 # Uncomment the line below to report garbage that is not
100 # freeable by reference counting alone. By default only
101 # garbage that is not collectable by the GC is reported.
102 #gc.set_debug(gc.DEBUG_SAVEALL)
Neil Schemenauerd569f232000-09-22 15:29:28 +0000103 found_garbage = []
Barry Warsawa873b032000-08-03 15:50:37 +0000104
Barry Warsawe11e3de1999-01-28 19:51:51 +0000105 if single:
106 from tempfile import gettempdir
107 filename = os.path.join(gettempdir(), 'pynexttest')
108 try:
109 fp = open(filename, 'r')
Eric S. Raymondfc170b12001-02-09 11:51:27 +0000110 next = fp.read().strip()
Barry Warsawe11e3de1999-01-28 19:51:51 +0000111 tests = [next]
112 fp.close()
113 except IOError:
114 pass
Guido van Rossuma4122201997-08-18 20:08:24 +0000115 for i in range(len(args)):
Guido van Rossum41360a41998-03-26 19:42:58 +0000116 # Strip trailing ".py" from arguments
117 if args[i][-3:] == '.py':
118 args[i] = args[i][:-3]
Guido van Rossum6c74fea1998-08-25 12:29:08 +0000119 stdtests = STDTESTS[:]
120 nottests = NOTTESTS[:]
Guido van Rossum152494a1996-12-20 03:12:20 +0000121 if exclude:
Guido van Rossum6c74fea1998-08-25 12:29:08 +0000122 for arg in args:
123 if arg in stdtests:
124 stdtests.remove(arg)
125 nottests[:0] = args
Guido van Rossum41360a41998-03-26 19:42:58 +0000126 args = []
Guido van Rossum747e1ca1998-08-24 13:48:36 +0000127 tests = tests or args or findtests(testdir, stdtests, nottests)
Barry Warsawe11e3de1999-01-28 19:51:51 +0000128 if single:
129 tests = tests[:1]
Skip Montanaroab1c7912000-06-30 16:39:27 +0000130 if randomize:
131 random.shuffle(tests)
Guido van Rossum41360a41998-03-26 19:42:58 +0000132 test_support.verbose = verbose # Tell tests to be moderately quiet
Trent Mickf29f47b2000-08-11 19:02:59 +0000133 test_support.use_large_resources = use_large_resources
Guido van Rossum5796d262000-04-21 21:35:06 +0000134 save_modules = sys.modules.keys()
Guido van Rossum152494a1996-12-20 03:12:20 +0000135 for test in tests:
Guido van Rossum41360a41998-03-26 19:42:58 +0000136 if not quiet:
137 print test
Trent Mickf29f47b2000-08-11 19:02:59 +0000138 ok = runtest(test, generate, verbose, quiet, testdir)
Guido van Rossum41360a41998-03-26 19:42:58 +0000139 if ok > 0:
140 good.append(test)
141 elif ok == 0:
142 bad.append(test)
143 else:
Guido van Rossum41360a41998-03-26 19:42:58 +0000144 skipped.append(test)
Neil Schemenauerd569f232000-09-22 15:29:28 +0000145 if findleaks:
146 gc.collect()
147 if gc.garbage:
Neil Schemenauer8a00abc2000-10-13 01:32:42 +0000148 print "Warning: test created", len(gc.garbage),
149 print "uncollectable object(s)."
150 # move the uncollectable objects somewhere so we don't see
151 # them again
Neil Schemenauerd569f232000-09-22 15:29:28 +0000152 found_garbage.extend(gc.garbage)
153 del gc.garbage[:]
Guido van Rossum5796d262000-04-21 21:35:06 +0000154 # Unload the newly imported modules (best effort finalization)
155 for module in sys.modules.keys():
Guido van Rossum51931142000-05-05 14:27:39 +0000156 if module not in save_modules and module.startswith("test."):
Guido van Rossum5796d262000-04-21 21:35:06 +0000157 test_support.unload(module)
Guido van Rossum152494a1996-12-20 03:12:20 +0000158 if good and not quiet:
Guido van Rossum41360a41998-03-26 19:42:58 +0000159 if not bad and not skipped and len(good) > 1:
160 print "All",
161 print count(len(good), "test"), "OK."
Tim Peters1a4d77b2000-12-30 22:21:22 +0000162 if verbose:
163 print "CAUTION: stdout isn't compared in verbose mode: a test"
164 print "that passes in verbose mode may fail without it."
Guido van Rossum152494a1996-12-20 03:12:20 +0000165 if bad:
Tim Petersa45da922001-08-12 03:45:50 +0000166 print count(len(bad), "test"), "failed:"
167 printlist(bad)
Guido van Rossum152494a1996-12-20 03:12:20 +0000168 if skipped and not quiet:
Tim Petersa45da922001-08-12 03:45:50 +0000169 print count(len(skipped), "test"), "skipped:"
170 printlist(skipped)
Barry Warsawe11e3de1999-01-28 19:51:51 +0000171
Tim Petersb5b7b782001-08-12 01:20:39 +0000172 e = _ExpectedSkips()
Tim Petersa2be2d62001-08-12 02:01:09 +0000173 plat = sys.platform
Tim Petersb5b7b782001-08-12 01:20:39 +0000174 if e.isvalid():
175 surprise = _Set(skipped) - e.getexpected()
Tim Petersb5b7b782001-08-12 01:20:39 +0000176 if surprise:
177 print count(len(surprise), "skip"), \
Tim Petersa45da922001-08-12 03:45:50 +0000178 "unexpected on", plat + ":"
179 printlist(surprise)
Tim Petersb5b7b782001-08-12 01:20:39 +0000180 else:
181 print "Those skips are all expected on", plat + "."
182 else:
183 print "Ask someone to teach regrtest.py about which tests are"
184 print "expected to get skipped on", plat + "."
185
Barry Warsawe11e3de1999-01-28 19:51:51 +0000186 if single:
187 alltests = findtests(testdir, stdtests, nottests)
188 for i in range(len(alltests)):
189 if tests[0] == alltests[i]:
190 if i == len(alltests) - 1:
191 os.unlink(filename)
192 else:
193 fp = open(filename, 'w')
194 fp.write(alltests[i+1] + '\n')
195 fp.close()
196 break
197 else:
198 os.unlink(filename)
199
Guido van Rossume8387011997-08-14 19:40:34 +0000200 return len(bad) > 0
Guido van Rossum152494a1996-12-20 03:12:20 +0000201
Guido van Rossum6fd83b71998-08-01 17:04:08 +0000202STDTESTS = [
Guido van Rossum152494a1996-12-20 03:12:20 +0000203 'test_grammar',
204 'test_opcodes',
205 'test_operations',
206 'test_builtin',
207 'test_exceptions',
208 'test_types',
209 ]
210
Guido van Rossum6fd83b71998-08-01 17:04:08 +0000211NOTTESTS = [
Guido van Rossum152494a1996-12-20 03:12:20 +0000212 'test_support',
213 'test_b1',
214 'test_b2',
Jeremy Hylton62e2c7e2001-02-28 17:48:06 +0000215 'test_future1',
216 'test_future2',
Jeremy Hylton8471a352001-08-20 20:33:42 +0000217 'test_future3',
Guido van Rossum152494a1996-12-20 03:12:20 +0000218 ]
219
Guido van Rossum6fd83b71998-08-01 17:04:08 +0000220def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
Guido van Rossum152494a1996-12-20 03:12:20 +0000221 """Return a list of all applicable test modules."""
Guido van Rossum6fd83b71998-08-01 17:04:08 +0000222 if not testdir: testdir = findtestdir()
Guido van Rossum152494a1996-12-20 03:12:20 +0000223 names = os.listdir(testdir)
224 tests = []
225 for name in names:
Guido van Rossum41360a41998-03-26 19:42:58 +0000226 if name[:5] == "test_" and name[-3:] == ".py":
227 modname = name[:-3]
228 if modname not in stdtests and modname not in nottests:
229 tests.append(modname)
Guido van Rossum152494a1996-12-20 03:12:20 +0000230 tests.sort()
231 return stdtests + tests
232
Trent Mickf29f47b2000-08-11 19:02:59 +0000233def runtest(test, generate, verbose, quiet, testdir = None):
Guido van Rossum6fd83b71998-08-01 17:04:08 +0000234 """Run a single test.
235 test -- the name of the test
236 generate -- if true, generate output, instead of running the test
237 and comparing it to a previously created output file
238 verbose -- if true, print more messages
Trent Mickf29f47b2000-08-11 19:02:59 +0000239 quiet -- if true, don't print 'skipped' messages (probably redundant)
Guido van Rossum6fd83b71998-08-01 17:04:08 +0000240 testdir -- test directory
241 """
Guido van Rossum152494a1996-12-20 03:12:20 +0000242 test_support.unload(test)
Guido van Rossum6fd83b71998-08-01 17:04:08 +0000243 if not testdir: testdir = findtestdir()
Guido van Rossum152494a1996-12-20 03:12:20 +0000244 outputdir = os.path.join(testdir, "output")
245 outputfile = os.path.join(outputdir, test)
246 try:
Guido van Rossum41360a41998-03-26 19:42:58 +0000247 if generate:
Fred Drakee51fe8d2001-05-29 17:10:51 +0000248 cfp = StringIO.StringIO()
Guido van Rossum41360a41998-03-26 19:42:58 +0000249 elif verbose:
250 cfp = sys.stdout
251 else:
252 cfp = Compare(outputfile)
Guido van Rossum152494a1996-12-20 03:12:20 +0000253 except IOError:
Guido van Rossum41360a41998-03-26 19:42:58 +0000254 cfp = None
255 print "Warning: can't open", outputfile
Guido van Rossum152494a1996-12-20 03:12:20 +0000256 try:
Guido van Rossum41360a41998-03-26 19:42:58 +0000257 save_stdout = sys.stdout
258 try:
259 if cfp:
260 sys.stdout = cfp
261 print test # Output file starts with test name
Tim Petersd9742212001-05-22 18:28:25 +0000262 the_module = __import__(test, globals(), locals(), [])
263 # Most tests run to completion simply as a side-effect of
264 # being imported. For the benefit of tests that can't run
265 # that way (like test_threaded_import), explicitly invoke
266 # their test_main() function (if it exists).
267 indirect_test = getattr(the_module, "test_main", None)
268 if indirect_test is not None:
269 indirect_test()
Jeremy Hyltonfff9e202000-07-11 15:15:31 +0000270 if cfp and not (generate or verbose):
271 cfp.close()
Guido van Rossum41360a41998-03-26 19:42:58 +0000272 finally:
273 sys.stdout = save_stdout
Thomas Wouters3af826e2000-08-04 13:17:51 +0000274 except (ImportError, test_support.TestSkipped), msg:
Trent Mickf29f47b2000-08-11 19:02:59 +0000275 if not quiet:
276 print "test", test,
277 print "skipped -- ", msg
Guido van Rossum41360a41998-03-26 19:42:58 +0000278 return -1
Fred Drakefe5c22a2000-08-18 16:04:05 +0000279 except KeyboardInterrupt:
280 raise
Guido van Rossum152494a1996-12-20 03:12:20 +0000281 except test_support.TestFailed, msg:
Guido van Rossum41360a41998-03-26 19:42:58 +0000282 print "test", test, "failed --", msg
283 return 0
Guido van Rossum9e48b271997-07-16 01:56:13 +0000284 except:
Guido van Rossum41360a41998-03-26 19:42:58 +0000285 type, value = sys.exc_info()[:2]
Fred Drake27c4b392000-08-23 20:34:40 +0000286 print "test", test, "crashed --", str(type) + ":", value
Guido van Rossum41360a41998-03-26 19:42:58 +0000287 if verbose:
288 traceback.print_exc(file=sys.stdout)
289 return 0
Guido van Rossum152494a1996-12-20 03:12:20 +0000290 else:
Fred Drakee51fe8d2001-05-29 17:10:51 +0000291 if generate:
292 output = cfp.getvalue()
293 if output == test + "\n":
294 if os.path.exists(outputfile):
295 # Write it since it already exists (and the contents
296 # may have changed), but let the user know it isn't
297 # needed:
298 fp = open(outputfile, "w")
299 fp.write(output)
300 fp.close()
301 print "output file", outputfile, \
302 "is no longer needed; consider removing it"
303 # else:
304 # We don't need it, so don't create it.
305 else:
306 fp = open(outputfile, "w")
307 fp.write(output)
308 fp.close()
Guido van Rossum41360a41998-03-26 19:42:58 +0000309 return 1
Guido van Rossum152494a1996-12-20 03:12:20 +0000310
311def findtestdir():
312 if __name__ == '__main__':
Guido van Rossum41360a41998-03-26 19:42:58 +0000313 file = sys.argv[0]
Guido van Rossum152494a1996-12-20 03:12:20 +0000314 else:
Guido van Rossum41360a41998-03-26 19:42:58 +0000315 file = __file__
Guido van Rossum152494a1996-12-20 03:12:20 +0000316 testdir = os.path.dirname(file) or os.curdir
317 return testdir
318
319def count(n, word):
320 if n == 1:
Guido van Rossum41360a41998-03-26 19:42:58 +0000321 return "%d %s" % (n, word)
Guido van Rossum152494a1996-12-20 03:12:20 +0000322 else:
Guido van Rossum41360a41998-03-26 19:42:58 +0000323 return "%d %ss" % (n, word)
Guido van Rossum152494a1996-12-20 03:12:20 +0000324
Tim Petersa45da922001-08-12 03:45:50 +0000325def printlist(x, width=70, indent=4):
326 """Print the elements of a sequence to stdout.
327
328 Optional arg width (default 70) is the maximum line length.
329 Optional arg indent (default 4) is the number of blanks with which to
330 begin each line.
331 """
332
333 line = ' ' * indent
334 for one in map(str, x):
335 w = len(line) + len(one)
336 if line[-1:] == ' ':
337 pad = ''
338 else:
339 pad = ' '
340 w += 1
341 if w > width:
342 print line
343 line = ' ' * indent + one
344 else:
345 line += pad + one
346 if len(line) > indent:
347 print line
348
Guido van Rossum152494a1996-12-20 03:12:20 +0000349class Compare:
350
351 def __init__(self, filename):
Fred Drakeae1bb172001-05-21 21:08:12 +0000352 if os.path.exists(filename):
353 self.fp = open(filename, 'r')
354 else:
355 self.fp = StringIO.StringIO(
356 os.path.basename(filename) + "\n")
Tim Peters1a4d77b2000-12-30 22:21:22 +0000357 self.stuffthatmatched = []
Guido van Rossum152494a1996-12-20 03:12:20 +0000358
359 def write(self, data):
Guido van Rossum41360a41998-03-26 19:42:58 +0000360 expected = self.fp.read(len(data))
Tim Peters1a4d77b2000-12-30 22:21:22 +0000361 if data == expected:
362 self.stuffthatmatched.append(expected)
363 else:
364 # This Compare instance is spoofing stdout, so we need to write
365 # to stderr instead.
366 from sys import stderr as e
367 print >> e, "The actual stdout doesn't match the expected stdout."
368 if self.stuffthatmatched:
369 print >> e, "This much did match (between asterisk lines):"
370 print >> e, "*" * 70
371 good = "".join(self.stuffthatmatched)
372 e.write(good)
373 if not good.endswith("\n"):
374 e.write("\n")
375 print >> e, "*" * 70
376 print >> e, "Then ..."
377 else:
378 print >> e, "The first write to stdout clashed:"
379 # Note that the prompts are the same length in next two lines.
380 # This is so what we expected and what we got line up.
381 print >> e, "We expected (repr):", `expected`
382 print >> e, "But instead we got:", `data`
383 raise test_support.TestFailed('Writing: ' + `data`+
384 ', expected: ' + `expected`)
Guido van Rossum152494a1996-12-20 03:12:20 +0000385
Guido van Rossume87ed5f1998-04-23 13:33:21 +0000386 def writelines(self, listoflines):
387 map(self.write, listoflines)
388
Guido van Rossum75fce301997-07-17 14:51:37 +0000389 def flush(self):
Guido van Rossum41360a41998-03-26 19:42:58 +0000390 pass
Guido van Rossum75fce301997-07-17 14:51:37 +0000391
Guido van Rossum152494a1996-12-20 03:12:20 +0000392 def close(self):
Guido van Rossum41360a41998-03-26 19:42:58 +0000393 leftover = self.fp.read()
394 if leftover:
Tim Peters1a4d77b2000-12-30 22:21:22 +0000395 raise test_support.TestFailed('Tail of expected stdout unseen: ' +
396 `leftover`)
Guido van Rossum41360a41998-03-26 19:42:58 +0000397 self.fp.close()
Guido van Rossum152494a1996-12-20 03:12:20 +0000398
399 def isatty(self):
Guido van Rossum41360a41998-03-26 19:42:58 +0000400 return 0
Guido van Rossum152494a1996-12-20 03:12:20 +0000401
Tim Petersb5b7b782001-08-12 01:20:39 +0000402class _Set:
403 def __init__(self, seq=[]):
404 data = self.data = {}
405 for x in seq:
406 data[x] = 1
407
408 def __len__(self):
409 return len(self.data)
410
411 def __sub__(self, other):
412 "Return set of all elements in self not in other."
413 result = _Set()
414 data = result.data = self.data.copy()
415 for x in other.data:
416 if x in data:
417 del data[x]
418 return result
419
Jeremy Hylton39f77bc2001-08-12 21:53:08 +0000420 def __iter__(self):
421 return iter(self.data)
422
Tim Petersb5b7b782001-08-12 01:20:39 +0000423 def tolist(self, sorted=1):
424 "Return _Set elements as a list."
425 data = self.data.keys()
426 if sorted:
427 data.sort()
428 return data
429
Guido van Rossumf73e30c2001-08-12 02:22:19 +0000430_expectations = {
431 'win32':
432 """
433 test_al
434 test_cd
435 test_cl
436 test_commands
437 test_crypt
438 test_dbm
439 test_dl
440 test_fcntl
441 test_fork1
442 test_gdbm
443 test_gl
444 test_grp
445 test_imgfile
446 test_largefile
447 test_linuxaudiodev
448 test_mhlib
449 test_nis
450 test_openpty
451 test_poll
452 test_pty
453 test_pwd
454 test_signal
455 test_socketserver
456 test_sunaudiodev
457 test_timing
458 """,
459 'linux2':
460 """
461 test_al
462 test_cd
463 test_cl
464 test_dl
465 test_gl
466 test_imgfile
467 test_largefile
468 test_nis
469 test_ntpath
470 test_socketserver
471 test_sunaudiodev
472 test_unicode_file
473 test_winreg
474 test_winsound
475 """,
476}
477
Tim Petersb5b7b782001-08-12 01:20:39 +0000478class _ExpectedSkips:
479 def __init__(self):
480 self.valid = 0
Guido van Rossumf73e30c2001-08-12 02:22:19 +0000481 if _expectations.has_key(sys.platform):
482 s = _expectations[sys.platform]
Tim Petersb5b7b782001-08-12 01:20:39 +0000483 self.expected = _Set(s.split())
Guido van Rossumf73e30c2001-08-12 02:22:19 +0000484 self.valid = 1
Tim Petersb5b7b782001-08-12 01:20:39 +0000485
486 def isvalid(self):
487 "Return true iff _ExpectedSkips knows about the current platform."
488 return self.valid
489
490 def getexpected(self):
491 """Return set of test names we expect to skip on current platform.
492
493 self.isvalid() must be true.
494 """
495
496 assert self.isvalid()
497 return self.expected
498
Guido van Rossum152494a1996-12-20 03:12:20 +0000499if __name__ == '__main__':
Guido van Rossume8387011997-08-14 19:40:34 +0000500 sys.exit(main())