MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_shebang_command_in_venv

Method test_shebang_command_in_venv

Lib/test/test_launcher.py:765–788  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

763 )
764
765 def test_shebang_command_in_venv(self):
766 stem = "python-that-is-not-on-path"
767
768 # First ensure that our test name doesn't exist, and the launcher does
769 # not match any installed env
770 with self.script(f'#! /usr/bin/env {stem} arg1') as script:
771 data = self.run_py([script], expect_returncode=103)
772
773 with self.fake_venv() as (venv_exe, env):
774 # Put a "normal" Python on PATH as a distraction.
775 # The active VIRTUAL_ENV should be preferred when the name isn't an
776 # exact match.
777 exe = Path(Path(venv_exe).name).absolute()
778 exe.touch()
779 self.addCleanup(exe.unlink)
780 env["PATH"] = f"{exe.parent};{os.environ['PATH']}"
781
782 with self.script(f'#! /usr/bin/env {stem} arg1') as script:
783 data = self.run_py([script], env=env)
784 self.assertEqual(data["stdout"].strip(), f"{quote(venv_exe)} arg1 {quote(script)}")
785
786 with self.script(f'#! /usr/bin/env {exe.stem} arg1') as script:
787 data = self.run_py([script], env=env)
788 self.assertEqual(data["stdout"].strip(), f"{quote(exe)} arg1 {quote(script)}")
789
790 def test_shebang_executable_extension(self):
791 with self.script('#! /usr/bin/env python3.99') as script:

Callers

nothing calls this directly

Calls 10

PathClass · 0.90
scriptMethod · 0.80
run_pyMethod · 0.80
fake_venvMethod · 0.80
absoluteMethod · 0.80
addCleanupMethod · 0.80
quoteFunction · 0.70
touchMethod · 0.45
assertEqualMethod · 0.45
stripMethod · 0.45

Tested by

no test coverage detected