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