MCPcopy
hub / github.com/pex-tool/pex / test_is_python_script

Function test_is_python_script

tests/test_executables.py:51–87  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

49
50
51def test_is_python_script(tmpdir):
52 # type: (Tempdir) -> None
53
54 exe = tmpdir.join("exe")
55
56 touch(exe)
57 assert not is_python_script(exe, check_executable=False)
58 assert not is_python_script(exe, check_executable=True)
59
60 def write_shebang(shebang):
61 # type: (str) -> None
62 with open(exe, "w") as fp:
63 fp.write(shebang)
64
65 write_shebang("#!python")
66 assert is_python_script(exe, check_executable=False)
67 assert not is_python_script(exe, check_executable=True)
68
69 def check_is_python_script(shebang=None):
70 # type: (Optional[str]) -> None
71 if shebang:
72 write_shebang(shebang)
73 assert is_python_script(exe, check_executable=not WINDOWS)
74
75 chmod_plus_x(exe)
76
77 check_is_python_script()
78 check_is_python_script("#!/usr/bin/python")
79 check_is_python_script("#!/usr/bin/python3")
80 check_is_python_script("#!/usr/bin/python3.13")
81 check_is_python_script("#!/usr/bin/python -sE")
82 check_is_python_script("#!/usr/bin/env python")
83 check_is_python_script("#!/usr/bin/env python2.7")
84 check_is_python_script("#!/usr/bin/env python -sE")
85 check_is_python_script("#!/usr/bin/env -S python")
86 check_is_python_script("#!/usr/bin/env -S python3")
87 check_is_python_script("#!/usr/bin/env -S python -sE")
88
89
90def test_pip_console_script_is_python_script(tmpdir):

Callers

nothing calls this directly

Calls 6

touchFunction · 0.90
is_python_scriptFunction · 0.90
chmod_plus_xFunction · 0.90
write_shebangFunction · 0.85
check_is_python_scriptFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected