MCPcopy
hub / github.com/pyinstaller/pyinstaller / test_bundled_shell_script

Function test_bundled_shell_script

tests/functional/test_misc.py:256–281  ·  view source on GitHub ↗
(pyi_builder, tmp_path)

Source from the content-addressed store, hash-verified

254@pytest.mark.linux
255@pytest.mark.darwin
256def test_bundled_shell_script(pyi_builder, tmp_path):
257 script_file = tmp_path / "test_script.sh"
258 with open(script_file, "w", encoding="utf-8") as fp:
259 if compat.is_termux:
260 # In Termux environment, /usr is usually a symbolic link to ${PREFIX}; but it may also not exist. So use
261 # ${PREFIX} directly...
262 prefix = os.environ.get('PREFIX', '/usr')
263 print(f'#!{prefix}/bin/env sh', file=fp)
264 else:
265 print('#!/usr/bin/env sh', file=fp)
266 print('echo "Hello world!"', file=fp)
267 script_file.chmod(0o755)
268
269 pyi_builder.test_source(
270 """
271 import os
272 import subprocess
273
274 script = os.path.join(os.path.dirname(__file__), 'test_script.sh')
275 output = subprocess.check_output(script, text=True)
276
277 print(output)
278 assert output.strip() == "Hello world!"
279 """,
280 pyi_args=['--add-data', f"{script_file}:."]
281 )
282
283
284# Test that a program importing `__main__` module does not pull in `PyInstaller` (or in the case of the test, the

Callers

nothing calls this directly

Calls 2

chmodMethod · 0.80
test_sourceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…