ยปCore Development>Code coverage>Lib/test/regrtest.py

Python code coverage for Lib/test/regrtest.py

#countcontent
1n/a#! /usr/bin/env python3
2n/a
3n/a"""
4n/aScript to run Python regression tests.
5n/a
6n/aRun this script with -h or --help for documentation.
7n/a"""
8n/a
9n/a# We import importlib *ASAP* in order to test #15386
10n/aimport importlib
11n/a
12n/aimport os
13n/aimport sys
14n/afrom test.libregrtest import main
15n/a
16n/a
17n/a# Alias for backward compatibility (just in case)
18n/amain_in_temp_cwd = main
19n/a
20n/a
21n/adef _main():
22n/a global __file__
23n/a
24n/a # Remove regrtest.py's own directory from the module search path. Despite
25n/a # the elimination of implicit relative imports, this is still needed to
26n/a # ensure that submodules of the test package do not inappropriately appear
27n/a # as top-level modules even when people (or buildbots!) invoke regrtest.py
28n/a # directly instead of using the -m switch
29n/a mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
30n/a i = len(sys.path) - 1
31n/a while i >= 0:
32n/a if os.path.abspath(os.path.normpath(sys.path[i])) == mydir:
33n/a del sys.path[i]
34n/a else:
35n/a i -= 1
36n/a
37n/a # findtestdir() gets the dirname out of __file__, so we have to make it
38n/a # absolute before changing the working directory.
39n/a # For example __file__ may be relative when running trace or profile.
40n/a # See issue #9323.
41n/a __file__ = os.path.abspath(__file__)
42n/a
43n/a # sanity check
44n/a assert __file__ == os.path.abspath(sys.argv[0])
45n/a
46n/a main()
47n/a
48n/a
49n/aif __name__ == '__main__':
50n/a _main()