Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commita262a06

Browse files
committed
Upgrade test fixture pip in venv without upgrade_deps
Because the upgrade_deps parameter to venv.create, as well asrelated functionality such as the EnvBuilder.upgrade_dependenciesmethod 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 virtualenvironment back from need_pip to with_pip, which may be moreintuitive.
1 parentdd8ee4f commita262a06

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

‎test/lib/helper.py‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
importlogging
1111
importos
1212
importos.pathasosp
13+
importsubprocess
14+
importsys
1315
importtempfile
1416
importtextwrap
1517
importtime
@@ -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
ifos.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+
ifwith_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+
ifsys.version_info< (3,12):
420+
command.append("setuptools")
421+
subprocess.check_output(command)
413422

414423
@property
415424
defenv_dir(self):

‎test/test_index.py‎

Lines 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‎

Lines 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)

[8]ページ先頭

©2009-2026 Movatter.jp