1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
from __future__ import annotations
from typing import TYPE_CHECKING
from tox.execute.util import shebang
if TYPE_CHECKING:
from pathlib import Path
def test_shebang_found(tmp_path: Path) -> None:
script_path = tmp_path / "a"
script_path.write_text("#! /bin/python \t-c\t")
assert shebang(str(script_path)) == ["/bin/python", "-c"]
def test_shebang_file_missing(tmp_path: Path) -> None:
script_path = tmp_path / "a"
assert shebang(str(script_path)) is None
def test_shebang_no_shebang(tmp_path: Path) -> None:
script_path = tmp_path / "a"
script_path.write_bytes(b"magic")
assert shebang(str(script_path)) is None
def test_shebang_non_utf8_file(tmp_path: Path) -> None:
script_path, content = tmp_path / "a", b"#!" + bytearray.fromhex("c0")
script_path.write_bytes(content)
assert shebang(str(script_path)) is None
|