(self, expected_cwd, python_arg, **kwargs)
| 429 | |
| 430 | # For use in the test_cwd* tests below. |
| 431 | def _assert_cwd(self, expected_cwd, python_arg, **kwargs): |
| 432 | # Invoke Python via Popen, and assert that (1) the call succeeds, |
| 433 | # and that (2) the current working directory of the child process |
| 434 | # matches *expected_cwd*. |
| 435 | p = subprocess.Popen([python_arg, "-c", |
| 436 | "import os, sys; " |
| 437 | "buf = sys.stdout.buffer; " |
| 438 | "buf.write(os.getcwd().encode()); " |
| 439 | "buf.flush(); " |
| 440 | "sys.exit(47)"], |
| 441 | stdout=subprocess.PIPE, |
| 442 | **kwargs) |
| 443 | self.addCleanup(p.stdout.close) |
| 444 | p.wait() |
| 445 | self.assertEqual(47, p.returncode) |
| 446 | normcase = os.path.normcase |
| 447 | self.assertEqual(normcase(expected_cwd), |
| 448 | normcase(p.stdout.read().decode())) |
| 449 | |
| 450 | def test_cwd(self): |
| 451 | # Check that cwd changes the cwd for the child process. |
no test coverage detected