@@ -228,32 +228,37 @@ def test_upgrade_dependencies(self):
228
228
builder = venv .EnvBuilder ()
229
229
bin_path = 'bin'
230
230
python_exe = os .path .split (sys .executable )[1 ]
231
+ expected_exe = os .path .basename (sys ._base_executable )
232
+
231
233
if sys .platform == 'win32' :
232
234
bin_path = 'Scripts'
233
235
if os .path .normcase (os .path .splitext (python_exe )[0 ]).endswith ('_d' ):
234
- python_exe = 'python_d.exe '
236
+ expected_exe = 'python_d'
235
237
else :
236
- python_exe = 'python.exe'
238
+ expected_exe = 'python'
239
+ python_exe = expected_exe + '.exe'
240
+
237
241
with tempfile .TemporaryDirectory () as fake_env_dir :
238
242
expect_exe = os .path .normcase (
239
- os .path .join (fake_env_dir , bin_path , python_exe )
243
+ os .path .join (fake_env_dir , bin_path , expected_exe )
240
244
)
241
245
if sys .platform == 'win32' :
242
246
expect_exe = os .path .normcase (os .path .realpath (expect_exe ))
243
247
244
248
def pip_cmd_checker (cmd , ** kwargs ):
245
- cmd [0 ] = os .path .normcase (cmd [0 ])
246
249
self .assertEqual (
247
- cmd ,
250
+ cmd [ 1 :] ,
248
251
[
249
- expect_exe ,
250
252
'-m' ,
251
253
'pip' ,
252
254
'install' ,
253
255
'--upgrade' ,
254
256
'pip' ,
255
257
]
256
258
)
259
+ exe_dir = os .path .normcase (os .path .dirname (cmd [0 ]))
260
+ expected_dir = os .path .normcase (os .path .dirname (expect_exe ))
261
+ self .assertEqual (exe_dir , expected_dir )
257
262
258
263
fake_context = builder .ensure_directories (fake_env_dir )
259
264
with patch ('venv.subprocess.check_output' , pip_cmd_checker ):
@@ -681,7 +686,8 @@ def test_zippath_from_non_installed_posix(self):
681
686
self .addCleanup (rmtree , non_installed_dir )
682
687
bindir = os .path .join (non_installed_dir , self .bindir )
683
688
os .mkdir (bindir )
684
- shutil .copy2 (sys .executable , bindir )
689
+ python_exe = os .path .basename (sys .executable )
690
+ shutil .copy2 (sys .executable , os .path .join (bindir , python_exe ))
685
691
libdir = os .path .join (non_installed_dir , platlibdir , self .lib [1 ])
686
692
os .makedirs (libdir )
687
693
landmark = os .path .join (libdir , "os.py" )
@@ -717,7 +723,7 @@ def test_zippath_from_non_installed_posix(self):
717
723
else :
718
724
additional_pythonpath_for_non_installed .append (
719
725
eachpath )
720
- cmd = [os .path .join (non_installed_dir , self .bindir , self . exe ),
726
+ cmd = [os .path .join (non_installed_dir , self .bindir , python_exe ),
721
727
"-m" ,
722
728
"venv" ,
723
729
"--without-pip" ,
@@ -748,7 +754,8 @@ def test_zippath_from_non_installed_posix(self):
748
754
subprocess .check_call (cmd , env = child_env )
749
755
# Now check the venv created from the non-installed python has
750
756
# correct zip path in pythonpath.
751
- cmd = [self .envpy (), '-S' , '-c' , 'import sys; print(sys.path)' ]
757
+ target_python = os .path .join (self .env_dir , self .bindir , python_exe )
758
+ cmd = [target_python , '-S' , '-c' , 'import sys; print(sys.path)' ]
752
759
out , err = check_output (cmd )
753
760
self .assertTrue (zip_landmark .encode () in out )
754
761
0 commit comments