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

Function test_is_script_posix

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

Source from the content-addressed store, hash-verified

19
20@pytest.mark.skipif(WINDOWS, reason="This test checks posix expectations of a script.")
21def test_is_script_posix(tmpdir):
22 # type: (Tempdir) -> None
23
24 exe = tmpdir.join("exe")
25
26 touch(exe)
27 assert not is_exe(exe)
28 assert not is_script(exe, pattern=None, check_executable=True)
29
30 chmod_plus_x(exe)
31 assert is_exe(exe)
32 assert not is_script(exe, pattern=None, check_executable=True)
33
34 with open(exe, "wb") as fp:
35 fp.write(bytearray([0xCA, 0xFE, 0xBA, 0xBE]))
36 assert not is_script(fp.name, pattern=None, check_executable=True)
37
38 with open(exe, "wb") as fp:
39 fp.write(b"#!/mystery\n")
40 fp.write(bytearray([0xCA, 0xFE, 0xBA, 0xBE]))
41 assert is_script(exe, pattern=None, check_executable=True)
42 assert is_script(exe, pattern=br"^/mystery", check_executable=True)
43 assert not is_script(exe, pattern=br"^python", check_executable=True)
44
45 os.chmod(exe, 0o665)
46 assert is_script(exe, pattern=None, check_executable=False)
47 assert not is_script(exe, pattern=None, check_executable=True)
48 assert not is_exe(exe)
49
50
51def test_is_python_script(tmpdir):

Callers

nothing calls this directly

Calls 6

touchFunction · 0.90
is_exeFunction · 0.90
is_scriptFunction · 0.90
chmod_plus_xFunction · 0.90
joinMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected