MCPcopy Index your code
hub / github.com/python/cpython / test_upgrade_dependencies

Method test_upgrade_dependencies

Lib/test/test_venv.py:221–259  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

219 self.assertIn("prompt = '%s'\n" % cwd, data)
220
221 def test_upgrade_dependencies(self):
222 builder = venv.EnvBuilder()
223 bin_path = 'bin'
224 python_exe = os.path.split(sys.executable)[1]
225 expected_exe = os.path.basename(sys._base_executable)
226
227 if sys.platform == 'win32':
228 bin_path = 'Scripts'
229 if os.path.normcase(os.path.splitext(python_exe)[0]).endswith('_d'):
230 expected_exe = 'python_d'
231 else:
232 expected_exe = 'python'
233 python_exe = expected_exe + '.exe'
234
235 with tempfile.TemporaryDirectory() as fake_env_dir:
236 expect_exe = os.path.normcase(
237 os.path.join(fake_env_dir, bin_path, expected_exe)
238 )
239 if sys.platform == 'win32':
240 expect_exe = os.path.normcase(os.path.realpath(expect_exe))
241
242 def pip_cmd_checker(cmd, **kwargs):
243 self.assertEqual(
244 cmd[1:],
245 [
246 '-m',
247 'pip',
248 'install',
249 '--upgrade',
250 'pip',
251 ]
252 )
253 exe_dir = os.path.normcase(os.path.dirname(cmd[0]))
254 expected_dir = os.path.normcase(os.path.dirname(expect_exe))
255 self.assertEqual(exe_dir, expected_dir)
256
257 fake_context = builder.ensure_directories(fake_env_dir)
258 with patch('venv.subprocess.check_output', pip_cmd_checker):
259 builder.upgrade_dependencies(fake_context)
260
261 @requireVenvCreate
262 def test_prefixes(self):

Callers

nothing calls this directly

Calls 8

patchFunction · 0.90
normcaseMethod · 0.80
splitextMethod · 0.80
splitMethod · 0.45
basenameMethod · 0.45
endswithMethod · 0.45
joinMethod · 0.45
realpathMethod · 0.45

Tested by

no test coverage detected