MCPcopy Index your code
hub / github.com/python/cpython / _main

Function _main

Lib/test/regrtest.py:18–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16
17
18def _main():
19 global __file__
20
21 # Remove regrtest.py's own directory from the module search path. Despite
22 # the elimination of implicit relative imports, this is still needed to
23 # ensure that submodules of the test package do not inappropriately appear
24 # as top-level modules even when people (or buildbots!) invoke regrtest.py
25 # directly instead of using the -m switch
26 mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
27 i = len(sys.path) - 1
28 while i >= 0:
29 if os.path.abspath(os.path.normpath(sys.path[i])) == mydir:
30 del sys.path[i]
31 else:
32 i -= 1
33
34 # findtestdir() gets the dirname out of __file__, so we have to make it
35 # absolute before changing the working directory.
36 # For example __file__ may be relative when running trace or profile.
37 # See issue #9323.
38 __file__ = os.path.abspath(__file__)
39
40 # sanity check
41 assert __file__ == os.path.abspath(sys.argv[0])
42
43 main()
44
45
46if __name__ == '__main__':

Callers 1

regrtest.pyFile · 0.70

Calls 3

mainFunction · 0.90
abspathMethod · 0.45
dirnameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…