diff options
Diffstat (limited to 'Lib/test/test_venv.py')
| -rw-r--r-- | Lib/test/test_venv.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index b462588..d2c986e 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -8,11 +8,12 @@ Licensed to the PSF under a contributor agreement. import ensurepip import os import os.path +import re import struct import subprocess import sys import tempfile -from test.support import (captured_stdout, captured_stderr, run_unittest, +from test.support import (captured_stdout, captured_stderr, can_symlink, EnvironmentVarGuard, rmtree) import textwrap import unittest @@ -25,6 +26,11 @@ try: except ImportError: ssl = None +try: + import threading +except ImportError: + threading = None + skipInVenv = unittest.skipIf(sys.prefix != sys.base_prefix, 'Test not appropriate in a venv') @@ -319,6 +325,8 @@ class EnsurePipTest(BaseTest): # 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') def test_with_pip(self): rmtree(self.env_dir) with EnvironmentVarGuard() as envvars: @@ -387,7 +395,15 @@ class EnsurePipTest(BaseTest): # We force everything to text, so unittest gives the detailed diff # if we get unexpected results err = err.decode("latin-1") # Force to text, prevent decoding errors - self.assertEqual(err, "") + # Ignore the warning: + # "The directory '$HOME/.cache/pip/http' or its parent directory + # is not owned by the current user and the cache has been disabled. + # Please check the permissions and owner of that directory. If + # executing pip with sudo, you may want sudo's -H flag." + # where $HOME is replaced by the HOME environment variable. + err = re.sub("^The directory .* or its parent directory is not owned " + "by the current user .*$", "", err, flags=re.MULTILINE) + self.assertEqual(err.rstrip(), "") # Being fairly specific regarding the expected behaviour for the # initial bundling phase in Python 3.4. If the output changes in # future pip versions, this test can likely be relaxed further. @@ -398,8 +414,5 @@ class EnsurePipTest(BaseTest): self.assert_pip_not_installed() -def test_main(): - run_unittest(BasicTest, EnsurePipTest) - if __name__ == "__main__": - test_main() + unittest.main() |
