Skip to content

gh-93005: Fixes launcher test when no Python install is available #93007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Lib/test/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def script(self, content, encoding="utf-8"):
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)
Expand Down Expand Up @@ -462,7 +462,7 @@ def test_py_default_in_list(self):
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)
Expand All @@ -482,9 +482,9 @@ def test_virtualenv_in_list(self):
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")
Expand Down
6 changes: 3 additions & 3 deletions PC/launcher2.c
Original file line number Diff line number Diff line change
Expand Up @@ -972,16 +972,16 @@ checkDefaults(SearchInfo *search)
if (!slash) {
search->tag = tag;
search->tagLength = n;
// gh-92817: allow a high priority env to be selected even if it
// doesn't match the tag
search->lowPriorityTag = true;
} else {
search->company = tag;
search->companyLength = (int)(slash - tag);
search->tag = slash + 1;
search->tagLength = n - (search->companyLength + 1);
search->oldStyleTag = false;
}
// gh-92817: allow a high priority env to be selected even if it
// doesn't match the tag
search->lowPriorityTag = true;
}

return 0;
Expand Down