(tmpdir)
| 49 | |
| 50 | |
| 51 | def 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 | |
| 90 | def test_pip_console_script_is_python_script(tmpdir): |
nothing calls this directly
no test coverage detected