[Python-checkins] gh-93005: Fixes launcher test when no Python install is available (GH-93007)
miss-islington
webhook-mailer at python.org
Mon May 23 12:42:46 EDT 2022
https://github.com/python/cpython/commit/8c5739e42598b62facaec0466c84560e1a348334
commit: 8c5739e42598b62facaec0466c84560e1a348334
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-05-23T09:42:41-07:00
summary:
gh-93005: Fixes launcher test when no Python install is available (GH-93007)
(cherry picked from commit 949dbf97ba09da3cfb243d5ad7f90967ad15f354)
Co-authored-by: Steve Dower <steve.dower at python.org>
files:
M Lib/test/test_launcher.py
M PC/launcher2.c
diff --git a/Lib/test/test_launcher.py b/Lib/test/test_launcher.py
index aeacbbecbfa12..8d9de688f0a53 100644
--- a/Lib/test/test_launcher.py
+++ b/Lib/test/test_launcher.py
@@ -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)
@@ -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)
@@ -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")
diff --git a/PC/launcher2.c b/PC/launcher2.c
index 763bc138ed71d..ae11f4f024a90 100644
--- a/PC/launcher2.c
+++ b/PC/launcher2.c
@@ -972,9 +972,6 @@ 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);
@@ -982,6 +979,9 @@ checkDefaults(SearchInfo *search)
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;
More information about the Python-checkins
mailing list