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

Function test_sys_path_leak_for_current

tests/test_interpreter.py:505–532  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

503
504
505def test_sys_path_leak_for_current(tmpdir):
506 # type: (Any) -> None
507
508 expected_sys_path = [
509 entry
510 for entry in json.loads(
511 subprocess.check_output(
512 args=[
513 sys.executable,
514 "-sE",
515 "-c",
516 "import json, sys; json.dump(sys.path, sys.stdout)",
517 ]
518 ).decode("utf-8")
519 )
520 # N.B.: We expect the PythonInterpreter infrastructure to elide the implicit "" / CWD
521 # sys.path entry.
522 if entry
523 ]
524 pex_root = os.path.join(str(tmpdir), "pex_root")
525
526 new_sys_path_entry = os.path.join(str(tmpdir), "not-interpreter-sys-path")
527 with ENV.patch(PEX_ROOT=pex_root), PythonInterpreter._cleared_memory_cache():
528 sys.path.append(new_sys_path_entry)
529 try:
530 assert tuple(expected_sys_path) == PythonInterpreter.get().sys_path
531 finally:
532 sys.path.pop()
533
534
535def test_create_shebang(tmpdir):

Callers

nothing calls this directly

Calls 7

decodeMethod · 0.80
_cleared_memory_cacheMethod · 0.80
appendMethod · 0.80
joinMethod · 0.45
patchMethod · 0.45
getMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected