@@ -328,13 +328,7 @@ def test_devnull_exists_and_is_empty(self):
328
328
with open (os .devnull , "rb" ) as f :
329
329
self .assertEqual (f .read (), b"" )
330
330
331
- # Requesting pip fails without SSL (http://bugs.python.org/issue19744)
332
- @unittest .skipIf (ssl is None , ensurepip ._MISSING_SSL_MESSAGE )
333
- @unittest .skipUnless (threading , 'some dependencies of pip import threading'
334
- ' module unconditionally' )
335
- # Issue #26610: pip/pep425tags.py requires ctypes
336
- @unittest .skipUnless (ctypes , 'pip requires ctypes' )
337
- def test_with_pip (self ):
331
+ def do_test_with_pip (self , system_site_packages ):
338
332
rmtree (self .env_dir )
339
333
with EnvironmentVarGuard () as envvars :
340
334
# pip's cross-version compatibility may trigger deprecation
@@ -368,6 +362,7 @@ def test_with_pip(self):
368
362
# config in place to ensure we ignore it
369
363
try :
370
364
self .run_with_capture (venv .create , self .env_dir ,
365
+ system_site_packages = system_site_packages ,
371
366
with_pip = True )
372
367
except subprocess .CalledProcessError as exc :
373
368
# The output this produces can be a little hard to read,
@@ -417,9 +412,21 @@ def test_with_pip(self):
417
412
out = out .decode ("latin-1" ) # Force to text, prevent decoding errors
418
413
self .assertIn ("Successfully uninstalled pip" , out )
419
414
self .assertIn ("Successfully uninstalled setuptools" , out )
420
- # Check pip is now gone from the virtual environment
421
- self .assert_pip_not_installed ()
415
+ # Check pip is now gone from the virtual environment. This only
416
+ # applies in the system_site_packages=False case, because in the
417
+ # other case, pip may still be available in the system site-packages
418
+ if not system_site_packages :
419
+ self .assert_pip_not_installed ()
422
420
421
+ # Requesting pip fails without SSL (http://bugs.python.org/issue19744)
422
+ @unittest .skipIf (ssl is None , ensurepip ._MISSING_SSL_MESSAGE )
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 )
423
430
424
431
if __name__ == "__main__" :
425
432
unittest .main ()
0 commit comments