diff options
author | Cooper Lees <cooper@fb.com> | 2019-06-17 18:18:14 (GMT) |
---|---|---|
committer | Ćukasz Langa <lukasz@langa.pl> | 2019-06-17 18:18:13 (GMT) |
commit | 4acdbf11b1fae1af24c47413a6caa593010d1b6f (patch) | |
tree | ecc8ede683fa9fc0067326deefd23af977e7284c /Lib/test/test_venv.py | |
parent | ca7b504a4d4c3a5fde1ee4607b9501c2bab6e743 (diff) | |
download | cpython-4acdbf11b1fae1af24c47413a6caa593010d1b6f.zip cpython-4acdbf11b1fae1af24c47413a6caa593010d1b6f.tar.gz cpython-4acdbf11b1fae1af24c47413a6caa593010d1b6f.tar.bz2 |
bpo-34556: Add --upgrade-deps to venv module (#13100)
Add --upgrade-deps to venv module
- This allows for pip + setuptools to be automatically upgraded to the latest version on PyPI
- Update documentation to represent this change
bpo-34556: Add --upgrade to venv module
Diffstat (limited to 'Lib/test/test_venv.py')
-rw-r--r-- | Lib/test/test_venv.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 24d3a69..4f6c11b 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -16,9 +16,9 @@ import tempfile from test.support import (captured_stdout, captured_stderr, requires_zlib, can_symlink, EnvironmentVarGuard, rmtree, import_module) -import threading import unittest import venv +from unittest.mock import patch try: import ctypes @@ -131,6 +131,28 @@ class BasicTest(BaseTest): self.assertEqual(context.prompt, '(My prompt) ') self.assertIn("prompt = 'My prompt'\n", data) + def test_upgrade_dependencies(self): + builder = venv.EnvBuilder() + bin_path = 'Scripts' if sys.platform == 'win32' else 'bin' + pip_exe = 'pip.exe' if sys.platform == 'win32' else 'pip' + with tempfile.TemporaryDirectory() as fake_env_dir: + + def pip_cmd_checker(cmd): + self.assertEqual( + cmd, + [ + os.path.join(fake_env_dir, bin_path, pip_exe), + 'install', + '-U', + 'pip', + 'setuptools' + ] + ) + + fake_context = builder.ensure_directories(fake_env_dir) + with patch('venv.subprocess.check_call', pip_cmd_checker): + builder.upgrade_dependencies(fake_context) + @requireVenvCreate def test_prefixes(self): """ |