bpo-41385: Fix test_executable_without_cwd on Windows (GH-21608)
https://github.com/python/cpython/commit/33cebe0b9a71da97046fc67c03062987c10... commit: 33cebe0b9a71da97046fc67c03062987c1049418 branch: 3.8 author: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> committer: GitHub <noreply@github.com> date: 2020-07-26T00:38:48-07:00 summary: bpo-41385: Fix test_executable_without_cwd on Windows (GH-21608) (cherry picked from commit b1a87300a06324c9fc7d6553906ed914489465aa) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> files: M Lib/test/test_subprocess.py diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index f8fee3687136f..2d3ab93555b4c 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -372,7 +372,9 @@ def _assert_cwd(self, expected_cwd, python_arg, **kwargs): # matches *expected_cwd*. p = subprocess.Popen([python_arg, "-c", "import os, sys; " - "sys.stdout.write(os.getcwd()); " + "buf = sys.stdout.buffer; " + "buf.write(os.getcwd().encode()); " + "buf.flush(); " "sys.exit(47)"], stdout=subprocess.PIPE, **kwargs) @@ -381,7 +383,7 @@ def _assert_cwd(self, expected_cwd, python_arg, **kwargs): self.assertEqual(47, p.returncode) normcase = os.path.normcase self.assertEqual(normcase(expected_cwd), - normcase(p.stdout.read().decode("utf-8"))) + normcase(p.stdout.read().decode())) def test_cwd(self): # Check that cwd changes the cwd for the child process.
participants (1)
-
Miss Islington (bot)