@@ -328,13 +328,7 @@ def test_devnull_exists_and_is_empty(self):
328328 with open (os .devnull , "rb" ) as f :
329329 self .assertEqual (f .read (), b"" )
330330
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 ):
338332 rmtree (self .env_dir )
339333 with EnvironmentVarGuard () as envvars :
340334 # pip's cross-version compatibility may trigger deprecation
@@ -368,6 +362,7 @@ def test_with_pip(self):
368362 # config in place to ensure we ignore it
369363 try :
370364 self .run_with_capture (venv .create , self .env_dir ,
365+ system_site_packages = system_site_packages ,
371366 with_pip = True )
372367 except subprocess .CalledProcessError as exc :
373368 # The output this produces can be a little hard to read,
@@ -417,9 +412,21 @@ def test_with_pip(self):
417412 out = out .decode ("latin-1" ) # Force to text, prevent decoding errors
418413 self .assertIn ("Successfully uninstalled pip" , out )
419414 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 ()
422420
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 )
423430
424431if __name__ == "__main__" :
425432 unittest .main ()
0 commit comments