Skip to content

Commit 8c5739e

Browse files
gh-93005: Fixes launcher test when no Python install is available (GH-93007)
(cherry picked from commit 949dbf9) Co-authored-by: Steve Dower <[email protected]>
1 parent acc998a commit 8c5739e

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Lib/test/test_launcher.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def script(self, content, encoding="utf-8"):
245245
file.unlink()
246246

247247
@contextlib.contextmanager
248-
def test_venv(self):
248+
def fake_venv(self):
249249
venv = Path.cwd() / "Scripts"
250250
venv.mkdir(exist_ok=True, parents=True)
251251
venv_exe = (venv / Path(sys.executable).name)
@@ -462,7 +462,7 @@ def test_py_default_in_list(self):
462462
self.assertEqual("PythonTestSuite/3.100", default)
463463

464464
def test_virtualenv_in_list(self):
465-
with self.test_venv() as (venv_exe, env):
465+
with self.fake_venv() as (venv_exe, env):
466466
data = self.run_py(["-0p"], env=env)
467467
for line in data["stdout"].splitlines():
468468
m = re.match(r"\s*\*\s+(.+)$", line)
@@ -482,9 +482,9 @@ def test_virtualenv_in_list(self):
482482
self.fail("did not find active venv entry")
483483

484484
def test_virtualenv_with_env(self):
485-
with self.test_venv() as (venv_exe, env):
486-
data1 = self.run_py([], env={**env, "PY_PYTHON": "-3"})
487-
data2 = self.run_py(["-3"], env={**env, "PY_PYTHON": "-3"})
485+
with self.fake_venv() as (venv_exe, env):
486+
data1 = self.run_py([], env={**env, "PY_PYTHON": "PythonTestSuite/3"})
487+
data2 = self.run_py(["-3"], env={**env, "PY_PYTHON": "PythonTestSuite/3"})
488488
# Compare stdout, because stderr goes via ascii
489489
self.assertEqual(data1["stdout"].strip(), str(venv_exe))
490490
self.assertEqual(data1["SearchInfo.lowPriorityTag"], "True")

PC/launcher2.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -972,16 +972,16 @@ checkDefaults(SearchInfo *search)
972972
if (!slash) {
973973
search->tag = tag;
974974
search->tagLength = n;
975-
// gh-92817: allow a high priority env to be selected even if it
976-
// doesn't match the tag
977-
search->lowPriorityTag = true;
978975
} else {
979976
search->company = tag;
980977
search->companyLength = (int)(slash - tag);
981978
search->tag = slash + 1;
982979
search->tagLength = n - (search->companyLength + 1);
983980
search->oldStyleTag = false;
984981
}
982+
// gh-92817: allow a high priority env to be selected even if it
983+
// doesn't match the tag
984+
search->lowPriorityTag = true;
985985
}
986986

987987
return 0;

0 commit comments

Comments
 (0)