mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-93005: Fixes launcher test when no Python install is available (GH-93007)
(cherry picked from commit 949dbf97ba
)
Co-authored-by: Steve Dower <steve.dower@python.org>
This commit is contained in:
parent
acc998a831
commit
8c5739e425
2 changed files with 8 additions and 8 deletions
|
@ -245,7 +245,7 @@ class RunPyMixin:
|
|||
file.unlink()
|
||||
|
||||
@contextlib.contextmanager
|
||||
def test_venv(self):
|
||||
def fake_venv(self):
|
||||
venv = Path.cwd() / "Scripts"
|
||||
venv.mkdir(exist_ok=True, parents=True)
|
||||
venv_exe = (venv / Path(sys.executable).name)
|
||||
|
@ -462,7 +462,7 @@ class TestLauncher(unittest.TestCase, RunPyMixin):
|
|||
self.assertEqual("PythonTestSuite/3.100", default)
|
||||
|
||||
def test_virtualenv_in_list(self):
|
||||
with self.test_venv() as (venv_exe, env):
|
||||
with self.fake_venv() as (venv_exe, env):
|
||||
data = self.run_py(["-0p"], env=env)
|
||||
for line in data["stdout"].splitlines():
|
||||
m = re.match(r"\s*\*\s+(.+)$", line)
|
||||
|
@ -482,9 +482,9 @@ class TestLauncher(unittest.TestCase, RunPyMixin):
|
|||
self.fail("did not find active venv entry")
|
||||
|
||||
def test_virtualenv_with_env(self):
|
||||
with self.test_venv() as (venv_exe, env):
|
||||
data1 = self.run_py([], env={**env, "PY_PYTHON": "-3"})
|
||||
data2 = self.run_py(["-3"], env={**env, "PY_PYTHON": "-3"})
|
||||
with self.fake_venv() as (venv_exe, env):
|
||||
data1 = self.run_py([], env={**env, "PY_PYTHON": "PythonTestSuite/3"})
|
||||
data2 = self.run_py(["-3"], env={**env, "PY_PYTHON": "PythonTestSuite/3"})
|
||||
# Compare stdout, because stderr goes via ascii
|
||||
self.assertEqual(data1["stdout"].strip(), str(venv_exe))
|
||||
self.assertEqual(data1["SearchInfo.lowPriorityTag"], "True")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue