Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a262a06

Browse filesBrowse files
committed
Upgrade test fixture pip in venv without upgrade_deps
Because the upgrade_deps parameter to venv.create, as well as related functionality such as the EnvBuilder.upgrade_dependencies method that it uses, are only available starting in Python 3.9. This also puts the name of the VirtualEnvironment.__init__ parameter for setting up pip in the test fixture virtual environment back from need_pip to with_pip, which may be more intuitive.
1 parent dd8ee4f commit a262a06
Copy full SHA for a262a06

File tree

3 files changed

+14
-5
lines changed
Filter options

3 files changed

+14
-5
lines changed

‎test/lib/helper.py

Copy file name to clipboardExpand all lines: test/lib/helper.py
+12-3Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import logging
1111
import os
1212
import os.path as osp
13+
import subprocess
14+
import sys
1315
import tempfile
1416
import textwrap
1517
import time
@@ -403,13 +405,20 @@ class VirtualEnvironment:
403405

404406
__slots__ = ("_env_dir",)
405407

406-
def __init__(self, env_dir, *, need_pip):
408+
def __init__(self, env_dir, *, with_pip):
407409
if os.name == "nt":
408410
self._env_dir = osp.realpath(env_dir)
409-
venv.create(self.env_dir, symlinks=False, with_pip=need_pip, upgrade_deps=need_pip)
411+
venv.create(self.env_dir, symlinks=False, with_pip=with_pip)
410412
else:
411413
self._env_dir = env_dir
412-
venv.create(self.env_dir, symlinks=True, with_pip=need_pip, upgrade_deps=need_pip)
414+
venv.create(self.env_dir, symlinks=True, with_pip=with_pip)
415+
416+
if with_pip:
417+
# The upgrade_deps parameter to venv.create is 3.9+ only, so do it this way.
418+
command = [self.python, "-m", "pip", "install", "--upgrade", "pip"]
419+
if sys.version_info < (3, 12):
420+
command.append("setuptools")
421+
subprocess.check_output(command)
413422

414423
@property
415424
def env_dir(self):

‎test/test_index.py

Copy file name to clipboardExpand all lines: test/test_index.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ def test_hook_uses_shell_not_from_cwd(self, rw_dir, case):
10601060
# from a venv may not run when copied outside of it, and a global interpreter
10611061
# won't run when copied to a different location if it was installed from the
10621062
# Microsoft Store. So we make a new venv in rw_dir and use its interpreter.
1063-
venv = VirtualEnvironment(rw_dir, need_pip=False)
1063+
venv = VirtualEnvironment(rw_dir, with_pip=False)
10641064
shutil.copy(venv.python, Path(rw_dir, shell_name))
10651065
shutil.copy(fixture_path("polyglot"), hook_path("polyglot", repo.git_dir))
10661066
payload = Path(rw_dir, "payload.txt")

‎test/test_installation.py

Copy file name to clipboardExpand all lines: test/test_installation.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_installation(self, rw_dir):
6464

6565
@staticmethod
6666
def _set_up_venv(rw_dir):
67-
venv = VirtualEnvironment(rw_dir, need_pip=True)
67+
venv = VirtualEnvironment(rw_dir, with_pip=True)
6868
os.symlink(
6969
os.path.dirname(os.path.dirname(__file__)),
7070
venv.sources,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.