]> granicus.if.org Git - python/commitdiff
Fixes #24875: Merged fix from 3.5.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Thu, 2 Feb 2017 19:17:02 +0000 (19:17 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Thu, 2 Feb 2017 19:17:02 +0000 (19:17 +0000)
1  2 
Lib/test/test_venv.py
Lib/venv/__init__.py

index 0ff978fc8ca2c8097b5565c3e306fdaf156a3c81,c1e656613bf49c98ccc31a938c2f870a0ae3aef5..2691632ff4f857a0a1b487c648e6590305ca07a5
@@@ -324,18 -327,8 +324,13 @@@ class EnsurePipTest(BaseTest)
          with open(os.devnull, "rb") as f:
              self.assertEqual(f.read(), b"")
  
-     @unittest.skipUnless(threading, 'some dependencies of pip import threading'
-                                     ' module unconditionally')
-     # Issue #26610: pip/pep425tags.py requires ctypes
-     @unittest.skipUnless(ctypes, 'pip requires ctypes')
-     def test_with_pip(self):
 +        # Issue #20541: os.path.exists('nul') is False on Windows
 +        if os.devnull.lower() == 'nul':
 +            self.assertFalse(os.path.exists(os.devnull))
 +        else:
 +            self.assertTrue(os.path.exists(os.devnull))
 +
+     def do_test_with_pip(self, system_site_packages):
          rmtree(self.env_dir)
          with EnvironmentVarGuard() as envvars:
              # pip's cross-version compatibility may trigger deprecation
          out = out.decode("latin-1") # Force to text, prevent decoding errors
          self.assertIn("Successfully uninstalled pip", out)
          self.assertIn("Successfully uninstalled setuptools", out)
-         # Check pip is now gone from the virtual environment
-         self.assert_pip_not_installed()
+         # Check pip is now gone from the virtual environment. This only
+         # applies in the system_site_packages=False case, because in the
+         # other case, pip may still be available in the system site-packages
+         if not system_site_packages:
+             self.assert_pip_not_installed()
  
 -    # Requesting pip fails without SSL (http://bugs.python.org/issue19744)
 -    @unittest.skipIf(ssl is None, ensurepip._MISSING_SSL_MESSAGE)
+     @unittest.skipUnless(threading, 'some dependencies of pip import threading'
+                                     ' module unconditionally')
+     # Issue #26610: pip/pep425tags.py requires ctypes
+     @unittest.skipUnless(ctypes, 'pip requires ctypes')
+     def test_with_pip(self):
+         self.do_test_with_pip(False)
+         self.do_test_with_pip(True)
  
  if __name__ == "__main__":
      unittest.main()
Simple merge