@@ -330,12 +330,7 @@ def test_devnull(self):
330
330
else :
331
331
self .assertTrue (os .path .exists (os .devnull ))
332
332
333
-
334
- @unittest .skipUnless (threading , 'some dependencies of pip import threading'
335
- ' module unconditionally' )
336
- # Issue #26610: pip/pep425tags.py requires ctypes
337
- @unittest .skipUnless (ctypes , 'pip requires ctypes' )
338
- def test_with_pip (self ):
333
+ def do_test_with_pip (self , system_site_packages ):
339
334
rmtree (self .env_dir )
340
335
with EnvironmentVarGuard () as envvars :
341
336
# pip's cross-version compatibility may trigger deprecation
@@ -369,6 +364,7 @@ def test_with_pip(self):
369
364
# config in place to ensure we ignore it
370
365
try :
371
366
self .run_with_capture (venv .create , self .env_dir ,
367
+ system_site_packages = system_site_packages ,
372
368
with_pip = True )
373
369
except subprocess .CalledProcessError as exc :
374
370
# The output this produces can be a little hard to read,
@@ -418,9 +414,19 @@ def test_with_pip(self):
418
414
out = out .decode ("latin-1" ) # Force to text, prevent decoding errors
419
415
self .assertIn ("Successfully uninstalled pip" , out )
420
416
self .assertIn ("Successfully uninstalled setuptools" , out )
421
- # Check pip is now gone from the virtual environment
422
- self .assert_pip_not_installed ()
417
+ # Check pip is now gone from the virtual environment. This only
418
+ # applies in the system_site_packages=False case, because in the
419
+ # other case, pip may still be available in the system site-packages
420
+ if not system_site_packages :
421
+ self .assert_pip_not_installed ()
423
422
423
+ @unittest .skipUnless (threading , 'some dependencies of pip import threading'
424
+ ' module unconditionally' )
425
+ # Issue #26610: pip/pep425tags.py requires ctypes
426
+ @unittest .skipUnless (ctypes , 'pip requires ctypes' )
427
+ def test_with_pip (self ):
428
+ self .do_test_with_pip (False )
429
+ self .do_test_with_pip (True )
424
430
425
431
if __name__ == "__main__" :
426
432
unittest .main ()
0 commit comments