|
23 | 23 | is_wasm32, |
24 | 24 | requires_venv_with_pip, TEST_HOME_DIR, |
25 | 25 | requires_resource, copy_python_src_ignore) |
26 | | -from test.support.os_helper import (can_symlink, EnvironmentVarGuard, rmtree, |
27 | | - TESTFN, FakePath) |
| 26 | +from test.support.os_helper import (can_symlink, change_cwd, EnvironmentVarGuard, |
| 27 | + rmtree, TESTFN, FakePath) |
28 | 28 | import unittest |
29 | 29 | import venv |
30 | 30 | from unittest.mock import patch, Mock |
@@ -318,11 +318,14 @@ def test_prefixes_with_non_normalised_executable(self): |
318 | 318 | self.addCleanup(rmtree, subdir) |
319 | 319 | relative_exe = os.path.join( |
320 | 320 | os.pardir, os.path.basename(self.env_dir), self.bindir, self.exe) |
321 | | - p = subprocess.run( |
322 | | - [relative_exe, '-c', |
323 | | - 'import sys; print(sys.prefix); print(sys.exec_prefix)'], |
324 | | - cwd=subdir, capture_output=True, encoding='utf-8', |
325 | | - env={**os.environ, 'PYTHONHOME': ''}) |
| 321 | + # Windows does not resolve a relative executable against subprocess's |
| 322 | + # cwd argument, so change directory in this process instead. |
| 323 | + with change_cwd(subdir): |
| 324 | + p = subprocess.run( |
| 325 | + [relative_exe, '-c', |
| 326 | + 'import sys; print(sys.prefix); print(sys.exec_prefix)'], |
| 327 | + capture_output=True, encoding='utf-8', |
| 328 | + env={**os.environ, 'PYTHONHOME': ''}) |
326 | 329 | self.assertEqual(p.returncode, 0, p.stderr) |
327 | 330 | self.assertNotIn('Unexpected value in sys.prefix', p.stderr) |
328 | 331 | self.assertNotIn('Unexpected value in sys.exec_prefix', p.stderr) |
|
0 commit comments