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

Function test_execute_interpreter_dashm_module

tests/test_pex.py:687–719  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

685
686
687def test_execute_interpreter_dashm_module():
688 # type: () -> None
689 with temporary_dir() as pex_chroot:
690 pex_builder = PEXBuilder(path=pex_chroot)
691 pex_builder.add_source(None, "foo/__init__.py")
692 with tempfile.NamedTemporaryFile(mode="w") as fp:
693 fp.write(
694 dedent(
695 """\
696 import os
697 import sys
698
699 print("{} {}".format(os.path.realpath(sys.argv[0]), " ".join(sys.argv[1:])))
700 """
701 )
702 )
703 fp.flush()
704 pex_builder.add_source(fp.name, "foo/bar.py")
705 pex_builder.freeze()
706 pex = PEX(pex_chroot)
707 process = pex.run(
708 args=["-m", "foo.bar", "one", "two"],
709 stdout=subprocess.PIPE,
710 stderr=subprocess.PIPE,
711 blocking=False,
712 )
713 stdout, stderr = process.communicate()
714
715 assert 0 == process.returncode
716 assert "{} one two\n".format(
717 os.path.realpath(os.path.join(pex_chroot, "foo/bar.py"))
718 ) == stdout.decode("utf-8")
719 assert b"" == stderr
720
721
722def test_execute_interpreter_dashm_module_with_python_options():

Callers

nothing calls this directly

Calls 10

add_sourceMethod · 0.95
freezeMethod · 0.95
runMethod · 0.95
temporary_dirFunction · 0.90
PEXBuilderClass · 0.90
PEXClass · 0.90
communicateMethod · 0.80
decodeMethod · 0.80
writeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected