5 This will find all modules whose name is "test_*" in the test
6 directory, and run them. Various command line options provide
11 -v: verbose -- run tests in verbose mode with output to stdout
12 -w: verbose2 -- re-run failed tests in verbose mode
13 -q: quiet -- don't print anything except if a test fails
14 -x: exclude -- arguments are tests to *exclude*
15 -s: single -- run only a single test (see below)
16 -S: slow -- print the slowest 10 tests
17 -r: random -- randomize test execution order
18 -f: fromfile -- read names of tests to run from a file (see below)
19 -l: findleaks -- if GC is available detect tests that leak memory
20 -u: use -- specify which special resource intensive tests to run
21 -h: help -- print this text and exit
22 -t: threshold -- call gc.set_threshold(N)
23 -T: coverage -- turn on code coverage using the trace module
24 -D: coverdir -- Directory where coverage files are put
25 -N: nocoverdir -- Put coverage files alongside modules
26 -L: runleaks -- run the leaks(1) command just before exit
27 -R: huntrleaks -- search for reference leaks (needs debug build, v. slow)
28 -M: memlimit -- run very large memory-consuming tests
30 If non-option arguments are present, they are names for tests to run,
31 unless -x is given, in which case they are names for tests not to run.
32 If no test names are given, all tests are run.
34 -T turns on code coverage tracing with the trace module.
36 -D specifies the directory where coverage files are put.
38 -N Put coverage files alongside modules.
40 -s means to run only a single test and exit. This is useful when
41 doing memory analysis on the Python interpreter (which tend to consume
42 too many resources to run the full regression test non-stop). The
43 file /tmp/pynexttest is read to find the next test to run. If this
44 file is missing, the first test_*.py file in testdir or on the command
45 line is used. (actually tempfile.gettempdir() is used instead of
48 -f reads the names of tests from the file given as f's argument, one
49 or more test names per line. Whitespace is ignored. Blank lines and
50 lines beginning with '#' are ignored. This is especially useful for
51 whittling down failures involving interactions among tests.
53 -L causes the leaks(1) command to be run just before exit if it exists.
54 leaks(1) is available on Mac OS X and presumably on some other
55 FreeBSD-derived systems.
57 -R runs each test several times and examines sys.gettotalrefcount() to
58 see if the test appears to be leaking references. The argument should
59 be of the form stab:run:fname where 'stab' is the number of times the
60 test is run to let gettotalrefcount settle down, 'run' is the number
61 of times further it is run and 'fname' is the name of the file the
62 reports are written to. These parameters all have defaults (5, 4 and
63 "reflog.txt" respectively), so the minimal invocation is '-R ::'.
65 -M runs tests that require an exorbitant amount of memory. These tests
66 typically try to ascertain containers keep working when containing more than
67 2 billion objects, which only works on 64-bit systems. There are also some
68 tests that try to exhaust the address space of the process, which only makes
69 sense on 32-bit systems with at least 2Gb of memory. The passed-in memlimit,
70 which is a string in the form of '2.5Gb', determines howmuch memory the
71 tests will limit themselves to (but they may go slightly over.) The number
72 shouldn't be more memory than the machine has (including swap memory). You
73 should also keep in mind that swap memory is generally much, much slower
74 than RAM, and setting memlimit to all available RAM or higher will heavily
75 tax the machine. On the other hand, it is no use running these tests with a
76 limit of less than 2.5Gb, and many require more than 20Gb. Tests that expect
77 to use more than memlimit memory will be skipped. The big-memory tests
78 generally run very, very long.
80 -u is used to specify which special resource intensive tests to run,
81 such as those requiring large file support or network connectivity.
82 The argument is a comma-separated list of words indicating the
83 resources to test. Currently only the following are defined:
85 all - Enable all special resources.
87 audio - Tests that use the audio device. (There are known
88 cases of broken audio drivers that can crash Python or
89 even the Linux kernel.)
91 curses - Tests that use curses and will modify the terminal's
92 state and output modes.
94 lib2to3 - Run the tests for 2to3 (They take a while.)
96 largefile - It is okay to run some test that may create huge
97 files. These tests can take a long time and may
98 consume >2GB of disk space temporarily.
100 network - It is okay to run tests that use external network
101 resource, e.g. testing SSL support for sockets.
103 bsddb - It is okay to run the bsddb testsuite, which takes
104 a long time to complete.
106 decimal - Test the decimal module against a large suite that
107 verifies compliance with standards.
109 compiler - Test the compiler package by compiling all the source
110 in the standard library and test suite. This takes
111 a long time. Enabling this resource also allows
112 test_tokenize to verify round-trip lexing on every
113 file in the test library.
115 subprocess Run all tests for the subprocess module.
117 urlfetch - It is okay to download files required on testing.
119 To enable all resources except one, use '-uall,-<resource>'. For
120 example, to run all the tests except for the bsddb tests, give the
121 option '-uall,-bsddb'.
134 # I see no other way to suppress these warnings;
135 # putting them in test_grammar.py has no effect:
136 warnings
.filterwarnings("ignore", "hex/oct constants", FutureWarning
,
137 ".*test.test_grammar$")
138 if sys
.maxint
> 0x7fffffff:
139 # Also suppress them in <string>, because for 64-bit platforms,
140 # that's where test_grammar.py hides them.
141 warnings
.filterwarnings("ignore", "hex/oct constants", FutureWarning
,
144 # Ignore ImportWarnings that only occur in the source tree,
145 # (because of modules with the same name as source-directories in Modules/)
146 for mod
in ("ctypes", "gzip", "zipfile", "tarfile", "encodings.zlib_codec",
147 "test.test_zipimport", "test.test_zlib", "test.test_zipfile",
148 "test.test_codecs", "test.string_tests"):
149 warnings
.filterwarnings(module
=".*%s$" % (mod
,),
150 action
="ignore", category
=ImportWarning
)
152 # MacOSX (a.k.a. Darwin) has a default stack size that is too small
153 # for deeply recursive regular expressions. We see this as crashes in
154 # the Python test suite when running test_re.py and test_sre.py. The
155 # fix is to set the stack limit to 2048.
156 # This approach may also be useful for other Unixy platforms that
157 # suffer from small default stack limits.
158 if sys
.platform
== 'darwin':
164 soft
, hard
= resource
.getrlimit(resource
.RLIMIT_STACK
)
165 newsoft
= min(hard
, max(soft
, 1024*2048))
166 resource
.setrlimit(resource
.RLIMIT_STACK
, (newsoft
, hard
))
168 from test
import test_support
170 RESOURCE_NAMES
= ('audio', 'curses', 'lib2to3', 'largefile', 'network',
171 'bsddb', 'decimal', 'compiler', 'subprocess', 'urlfetch')
174 def usage(code
, msg
=''):
180 def main(tests
=None, testdir
=None, verbose
=0, quiet
=False,
181 exclude
=False, single
=False, randomize
=False, fromfile
=None,
182 findleaks
=False, use_resources
=None, trace
=False, coverdir
='coverage',
183 runleaks
=False, huntrleaks
=False, verbose2
=False, print_slow
=False):
184 """Execute a test suite.
186 This also parses command-line options and modifies its behavior
189 tests -- a list of strings containing test names (optional)
190 testdir -- the directory in which to look for tests (optional)
192 Users other than the Python test suite will certainly want to
193 specify testdir; if it's omitted, the directory containing the
194 Python test suite is searched for.
196 If the tests argument is omitted, the tests listed on the
197 command-line will be used. If that's empty, too, then all *.py
198 files beginning with test_ will be used.
200 The other default arguments (verbose, quiet, exclude,
201 single, randomize, findleaks, use_resources, trace, coverdir, and
202 print_slow) allow programmers calling main() directly to set the
203 values that would normally be set by flags on the command line.
206 test_support
.record_original_stdout(sys
.stdout
)
208 opts
, args
= getopt
.getopt(sys
.argv
[1:], 'hvgqxsSrf:lu:t:TD:NLR:wM:',
209 ['help', 'verbose', 'quiet', 'exclude',
210 'single', 'slow', 'random', 'fromfile',
211 'findleaks', 'use=', 'threshold=', 'trace',
212 'coverdir=', 'nocoverdir', 'runleaks',
213 'huntrleaks=', 'verbose2', 'memlimit=',
215 except getopt
.error
, msg
:
219 if use_resources
is None:
222 if o
in ('-h', '--help'):
224 elif o
in ('-v', '--verbose'):
226 elif o
in ('-w', '--verbose2'):
228 elif o
in ('-q', '--quiet'):
231 elif o
in ('-x', '--exclude'):
233 elif o
in ('-s', '--single'):
235 elif o
in ('-S', '--slow'):
237 elif o
in ('-r', '--randomize'):
239 elif o
in ('-f', '--fromfile'):
241 elif o
in ('-l', '--findleaks'):
243 elif o
in ('-L', '--runleaks'):
245 elif o
in ('-t', '--threshold'):
247 gc
.set_threshold(int(a
))
248 elif o
in ('-T', '--coverage'):
250 elif o
in ('-D', '--coverdir'):
251 coverdir
= os
.path
.join(os
.getcwd(), a
)
252 elif o
in ('-N', '--nocoverdir'):
254 elif o
in ('-R', '--huntrleaks'):
255 huntrleaks
= a
.split(':')
256 if len(huntrleaks
) != 3:
258 usage(2, '-R takes three colon-separated arguments')
259 if len(huntrleaks
[0]) == 0:
262 huntrleaks
[0] = int(huntrleaks
[0])
263 if len(huntrleaks
[1]) == 0:
266 huntrleaks
[1] = int(huntrleaks
[1])
267 if len(huntrleaks
[2]) == 0:
268 huntrleaks
[2] = "reflog.txt"
269 elif o
in ('-M', '--memlimit'):
270 test_support
.set_memlimit(a
)
271 elif o
in ('-u', '--use'):
272 u
= [x
.lower() for x
in a
.split(',')]
275 use_resources
[:] = RESOURCE_NAMES
281 if r
not in RESOURCE_NAMES
:
282 usage(1, 'Invalid -u/--use option: ' + a
)
284 if r
in use_resources
:
285 use_resources
.remove(r
)
286 elif r
not in use_resources
:
287 use_resources
.append(r
)
288 if single
and fromfile
:
289 usage(2, "-s and -f don't go together!")
294 resource_denieds
= []
300 print 'No GC available, disabling findleaks.'
303 # Uncomment the line below to report garbage that is not
304 # freeable by reference counting alone. By default only
305 # garbage that is not collectable by the GC is reported.
306 #gc.set_debug(gc.DEBUG_SAVEALL)
310 from tempfile
import gettempdir
311 filename
= os
.path
.join(gettempdir(), 'pynexttest')
313 fp
= open(filename
, 'r')
314 next
= fp
.read().strip()
324 guts
= line
.split() # assuming no test has whitespace in its name
325 if guts
and not guts
[0].startswith('#'):
329 # Strip .py extensions.
331 args
= map(removepy
, args
)
333 tests
= map(removepy
, tests
)
335 stdtests
= STDTESTS
[:]
336 nottests
= NOTTESTS
[:]
343 tests
= tests
or args
or findtests(testdir
, stdtests
, nottests
)
347 random
.shuffle(tests
)
350 tracer
= trace
.Trace(ignoredirs
=[sys
.prefix
, sys
.exec_prefix
],
351 trace
=False, count
=True)
353 test_support
.verbose
= verbose
# Tell tests to be moderately quiet
354 test_support
.use_resources
= use_resources
355 save_modules
= sys
.modules
.keys()
361 # If we're tracing code coverage, then we don't exit with status
362 # if on a false return value from main.
363 tracer
.runctx('runtest(test, verbose, quiet,'
364 ' test_times, testdir)',
365 globals=globals(), locals=vars())
368 ok
= runtest(test
, verbose
, quiet
, test_times
,
370 except KeyboardInterrupt:
371 # print a newline separate from the ^C
383 resource_denieds
.append(test
)
387 print "Warning: test created", len(gc
.garbage
),
388 print "uncollectable object(s)."
389 # move the uncollectable objects somewhere so we don't see
391 found_garbage
.extend(gc
.garbage
)
393 # Unload the newly imported modules (best effort finalization)
394 for module
in sys
.modules
.keys():
395 if module
not in save_modules
and module
.startswith("test."):
396 test_support
.unload(module
)
398 # The lists won't be sorted if running with -r
403 if good
and not quiet
:
404 if not bad
and not skipped
and len(good
) > 1:
406 print count(len(good
), "test"), "OK."
408 test_times
.sort(reverse
=True)
409 print "10 slowest tests:"
410 for time
, test
in test_times
[:10]:
411 print "%s: %.1fs" % (test
, time
)
413 print count(len(bad
), "test"), "failed:"
415 if skipped
and not quiet
:
416 print count(len(skipped
), "test"), "skipped:"
422 surprise
= set(skipped
) - e
.getexpected() - set(resource_denieds
)
424 print count(len(surprise
), "skip"), \
425 "unexpected on", plat
+ ":"
428 print "Those skips are all expected on", plat
+ "."
430 print "Ask someone to teach regrtest.py about which tests are"
431 print "expected to get skipped on", plat
+ "."
434 print "Re-running failed tests in verbose mode"
436 print "Re-running test %r in verbose mode" % test
439 test_support
.verbose
= True
440 ok
= runtest(test
, True, quiet
, test_times
, testdir
,
442 except KeyboardInterrupt:
443 # print a newline separate from the ^C
450 alltests
= findtests(testdir
, stdtests
, nottests
)
451 for i
in range(len(alltests
)):
452 if tests
[0] == alltests
[i
]:
453 if i
== len(alltests
) - 1:
456 fp
= open(filename
, 'w')
457 fp
.write(alltests
[i
+1] + '\n')
465 r
.write_results(show_missing
=True, summary
=True, coverdir
=coverdir
)
468 os
.system("leaks %d" % os
.getpid())
470 sys
.exit(len(bad
) > 0)
491 def findtests(testdir
=None, stdtests
=STDTESTS
, nottests
=NOTTESTS
):
492 """Return a list of all applicable test modules."""
493 if not testdir
: testdir
= findtestdir()
494 names
= os
.listdir(testdir
)
497 if name
[:5] == "test_" and name
[-3:] == os
.extsep
+"py":
499 if modname
not in stdtests
and modname
not in nottests
:
500 tests
.append(modname
)
502 return stdtests
+ tests
504 def runtest(test
, verbose
, quiet
, test_times
,
505 testdir
=None, huntrleaks
=False):
506 """Run a single test.
508 test -- the name of the test
509 verbose -- if true, print more messages
510 quiet -- if true, don't print 'skipped' messages (probably redundant)
511 test_times -- a list of (time, test_name) pairs
512 testdir -- test directory
513 huntrleaks -- run multiple times to test for leaks; requires a debug
514 build; a triple corresponding to -R's three arguments
516 -2 test skipped because resource denied
517 -1 test skipped for some other reason
523 return runtest_inner(test
, verbose
, quiet
, test_times
,
526 cleanup_test_droppings(test
, verbose
)
528 def runtest_inner(test
, verbose
, quiet
, test_times
,
529 testdir
=None, huntrleaks
=False):
530 test_support
.unload(test
)
532 testdir
= findtestdir()
534 capture_stdout
= None
536 capture_stdout
= cStringIO
.StringIO()
539 save_stdout
= sys
.stdout
542 sys
.stdout
= capture_stdout
543 if test
.startswith('test.'):
546 # Always import it from the test package
547 abstest
= 'test.' + test
548 start_time
= time
.time()
549 the_package
= __import__(abstest
, globals(), locals(), [])
550 the_module
= getattr(the_package
, test
)
551 # Old tests run to completion simply as a side-effect of
552 # being imported. For tests based on unittest or doctest,
553 # explicitly invoke their test_main() function (if it exists).
554 indirect_test
= getattr(the_module
, "test_main", None)
555 if indirect_test
is not None:
558 dash_R(the_module
, test
, indirect_test
, huntrleaks
)
559 test_time
= time
.time() - start_time
560 test_times
.append((test_time
, test
))
562 sys
.stdout
= save_stdout
563 except test_support
.ResourceDenied
, msg
:
565 print test
, "skipped --", msg
568 except (ImportError, test_support
.TestSkipped
), msg
:
570 print test
, "skipped --", msg
573 except KeyboardInterrupt:
575 except test_support
.TestFailed
, msg
:
576 print "test", test
, "failed --", msg
580 type, value
= sys
.exc_info()[:2]
581 print "test", test
, "crashed --", str(type) + ":", value
584 traceback
.print_exc(file=sys
.stdout
)
588 # Except in verbose mode, tests should not print anything
589 if verbose
or huntrleaks
:
591 output
= capture_stdout
.getvalue()
594 print "test", test
, "produced unexpected output:"
601 def cleanup_test_droppings(testname
, verbose
):
604 # Try to clean up junk commonly left behind. While tests shouldn't leave
605 # any files or directories behind, when a test fails that can be tedious
606 # for it to arrange. The consequences can be especially nasty on Windows,
607 # since if a test leaves a file open, it cannot be deleted by name (while
608 # there's nothing we can do about that here either, we can display the
609 # name of the offending test, which is a real help).
610 for name
in (test_support
.TESTFN
,
613 if not os
.path
.exists(name
):
616 if os
.path
.isdir(name
):
617 kind
, nuker
= "directory", shutil
.rmtree
618 elif os
.path
.isfile(name
):
619 kind
, nuker
= "file", os
.unlink
621 raise SystemError("os.path says %r exists but is neither "
622 "directory nor file" % name
)
625 print "%r left behind %s %r" % (testname
, kind
, name
)
628 except Exception, msg
:
629 print >> sys
.stderr
, ("%r left behind %s %r and it couldn't be "
630 "removed: %s" % (testname
, kind
, name
, msg
))
632 def dash_R(the_module
, test
, indirect_test
, huntrleaks
):
633 # This code is hackish and inelegant, but it seems to do the job.
634 import copy_reg
, _abcoll
, io
636 if not hasattr(sys
, 'gettotalrefcount'):
637 raise Exception("Tracking reference leaks requires a debug build "
640 # Save current values for dash_R_cleanup() to restore.
641 fs
= warnings
.filters
[:]
642 ps
= copy_reg
.dispatch_table
.copy()
643 pic
= sys
.path_importer_cache
.copy()
645 modules
= _abcoll
, io
646 for abc
in [getattr(mod
, a
) for mod
in modules
for a
in mod
.__all
__]:
647 # XXX isinstance(abc, ABCMeta) leads to infinite recursion
648 if not hasattr(abc
, '_abc_registry'):
650 for obj
in abc
.__subclasses
__() + [abc
]:
651 abcs
[obj
] = obj
._abc
_registry
.copy()
661 nwarmup
, ntracked
, fname
= huntrleaks
662 repcount
= nwarmup
+ ntracked
663 print >> sys
.stderr
, "beginning", repcount
, "repetitions"
664 print >> sys
.stderr
, ("1234567890"*(repcount
//10 + 1))[:repcount
]
665 dash_R_cleanup(fs
, ps
, pic
, abcs
)
666 for i
in range(repcount
):
667 rc
= sys
.gettotalrefcount()
669 sys
.stderr
.write('.')
670 dash_R_cleanup(fs
, ps
, pic
, abcs
)
672 deltas
.append(sys
.gettotalrefcount() - rc
- 2)
675 msg
= '%s leaked %s references, sum=%s' % (test
, deltas
, sum(deltas
))
676 print >> sys
.stderr
, msg
677 refrep
= open(fname
, "a")
681 def dash_R_cleanup(fs
, ps
, pic
, abcs
):
683 import _strptime
, linecache
684 dircache
= test_support
.import_module('dircache', deprecated
=True)
685 import urlparse
, urllib
, urllib2
, mimetypes
, doctest
686 import struct
, filecmp
687 from distutils
.dir_util
import _path_created
689 # Clear the warnings registry, so they can be displayed again
690 for mod
in sys
.modules
.values():
691 if hasattr(mod
, '__warningregistry__'):
692 del mod
.__warningregistry
__
694 # Restore some original values.
695 warnings
.filters
[:] = fs
696 copy_reg
.dispatch_table
.clear()
697 copy_reg
.dispatch_table
.update(ps
)
698 sys
.path_importer_cache
.clear()
699 sys
.path_importer_cache
.update(pic
)
702 sys
._clear
_type
_cache
()
704 # Clear ABC registries, restoring previously saved ABC registries.
705 for abc
, registry
in abcs
.items():
706 abc
._abc
_registry
= registry
.copy()
707 abc
._abc
_cache
.clear()
708 abc
._abc
_negative
_cache
.clear()
710 # Clear assorted module caches.
711 _path_created
.clear()
713 _strptime
._regex
_cache
.clear()
714 urlparse
.clear_cache()
716 urllib2
.install_opener(None)
718 linecache
.clearcache()
719 mimetypes
._default
_mime
_types
()
720 filecmp
._cache
.clear()
722 doctest
.master
= None
724 # Collect cyclic trash.
728 if __name__
== '__main__':
732 testdir
= os
.path
.dirname(file) or os
.curdir
736 if name
.endswith(os
.extsep
+ "py"):
742 return "%d %s" % (n
, word
)
744 return "%d %ss" % (n
, word
)
746 def printlist(x
, width
=70, indent
=4):
747 """Print the elements of iterable x to stdout.
749 Optional arg width (default 70) is the maximum line length.
750 Optional arg indent (default 4) is the number of blanks with which to
754 from textwrap
import fill
755 blanks
= ' ' * indent
756 print fill(' '.join(map(str, x
)), width
,
757 initial_indent
=blanks
, subsequent_indent
=blanks
)
759 # Map sys.platform to a string containing the basenames of tests
760 # expected to be skipped on that platform.
764 # The _ExpectedSkips constructor adds this to the set of expected
765 # skips if not os.path.supports_unicode_filenames.
767 # Controlled by test_socket_ssl.skip_expected. Requires the network
768 # resource, and a socket module with ssl support.
770 # Controlled by test_timeout.skip_expected. Requires the network
771 # resource and a socket module.
773 # Tests that are expected to be skipped everywhere except on one platform
774 # are also handled separately.
902 test_threadedtempfile
934 test_threadedtempfile
1097 _expectations
['freebsd5'] = _expectations
['freebsd4']
1098 _expectations
['freebsd6'] = _expectations
['freebsd4']
1099 _expectations
['freebsd7'] = _expectations
['freebsd4']
1100 _expectations
['freebsd8'] = _expectations
['freebsd4']
1102 class _ExpectedSkips
:
1105 from test
import test_timeout
1108 if sys
.platform
in _expectations
:
1109 s
= _expectations
[sys
.platform
]
1110 self
.expected
= set(s
.split())
1112 # expected to be skipped on every platform, even Linux
1113 self
.expected
.add('test_linuxaudiodev')
1115 if not os
.path
.supports_unicode_filenames
:
1116 self
.expected
.add('test_pep277')
1119 from test
import test_socket_ssl
1123 if test_socket_ssl
.skip_expected
:
1124 self
.expected
.add('test_socket_ssl')
1126 if test_timeout
.skip_expected
:
1127 self
.expected
.add('test_timeout')
1129 if sys
.maxint
== 9223372036854775807L:
1130 self
.expected
.add('test_imageop')
1132 if not sys
.platform
in ("mac", "darwin"):
1133 MAC_ONLY
= ["test_macos", "test_macostools", "test_aepack",
1134 "test_plistlib", "test_scriptpackages",
1136 for skip
in MAC_ONLY
:
1137 self
.expected
.add(skip
)
1138 elif len(u
'\0'.encode('unicode-internal')) == 4:
1139 self
.expected
.add("test_macostools")
1142 if sys
.platform
!= "win32":
1143 # test_sqlite is only reliable on Windows where the library
1144 # is distributed with Python
1145 WIN_ONLY
= ["test_unicode_file", "test_winreg",
1146 "test_winsound", "test_startfile",
1148 for skip
in WIN_ONLY
:
1149 self
.expected
.add(skip
)
1151 if sys
.platform
!= 'irix':
1152 IRIX_ONLY
= ["test_imageop", "test_al", "test_cd", "test_cl",
1153 "test_gl", "test_imgfile"]
1154 for skip
in IRIX_ONLY
:
1155 self
.expected
.add(skip
)
1157 if sys
.platform
!= 'sunos5':
1158 self
.expected
.add('test_sunaudiodev')
1159 self
.expected
.add('test_nis')
1161 if not sys
.py3kwarning
:
1162 self
.expected
.add('test_py3kwarn')
1167 "Return true iff _ExpectedSkips knows about the current platform."
1170 def getexpected(self
):
1171 """Return set of test names we expect to skip on current platform.
1173 self.isvalid() must be true.
1176 assert self
.isvalid()
1177 return self
.expected
1179 if __name__
== '__main__':
1180 # Remove regrtest.py's own directory from the module search path. This
1181 # prevents relative imports from working, and relative imports will screw
1182 # up the testing framework. E.g. if both test.test_support and
1183 # test_support are imported, they will not contain the same globals, and
1184 # much of the testing framework relies on the globals in the
1185 # test.test_support module.
1186 mydir
= os
.path
.abspath(os
.path
.normpath(os
.path
.dirname(sys
.argv
[0])))
1187 i
= pathlen
= len(sys
.path
)
1190 if os
.path
.abspath(os
.path
.normpath(sys
.path
[i
])) == mydir
:
1192 if len(sys
.path
) == pathlen
:
1193 print 'Could not find %r in sys.path to remove it' % mydir