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

Function test_binary_path

tests/tools/commands/test_venv.py:243–284  ·  view source on GitHub ↗
(
    tmpdir,  # type: Tempdir
    create_pex_venv,  # type: CreatePexVenv
)

Source from the content-addressed store, hash-verified

241
242
243def test_binary_path(
244 tmpdir, # type: Tempdir
245 create_pex_venv, # type: CreatePexVenv
246):
247 # type: (...) -> None
248
249 code = dedent(
250 """\
251 import errno
252 import subprocess
253 import sys
254
255 # PEXed code should be able to find all (console) scripts on the $PATH when the venv is
256 # created with --bin-path set, and the scripts should all run with the venv interpreter in
257 # order to find their code.
258
259 def try_invoke(*args):
260 try:
261 subprocess.check_call(list(args))
262 return 0
263 except OSError as e:
264 if e.errno == errno.ENOENT:
265 # This is what we expect when scripts are not set up on PATH via --bin-path.
266 return 1
267 return 2
268
269 exit_code = try_invoke("fab", "-V")
270 exit_code += 10 * try_invoke("inv", "-V")
271 exit_code += 100 * try_invoke("invoke", "-V")
272 sys.exit(exit_code)
273 """
274 )
275
276 venv = create_pex_venv()
277 returncode, stdout, stderr = execute_venv_pex_interpreter(
278 venv, extra_args=("-c", code), PATH=str(tmpdir)
279 )
280 assert 111 == returncode, stdout + stderr
281
282 venv_bin_path = create_pex_venv("-f", "--bin-path", "prepend")
283 returncode, _, _ = execute_venv_pex_interpreter(venv_bin_path, code=code, PATH=str(tmpdir))
284 assert 0 == returncode
285
286
287@pytest.mark.skipif(

Callers

nothing calls this directly

Calls 2

create_pex_venvFunction · 0.85

Tested by

no test coverage detected