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