bpo-41385: Fix test_executable_without_cwd on Windows (GH-21608)

(cherry picked from commit b1a87300a0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2020-07-26 00:38:52 -07:00 committed by GitHub
parent b74e536075
commit 8b7544cd02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -373,7 +373,9 @@ class ProcessTestCase(BaseTestCase):
# matches *expected_cwd*. # matches *expected_cwd*.
p = subprocess.Popen([python_arg, "-c", p = subprocess.Popen([python_arg, "-c",
"import os, sys; " "import os, sys; "
"sys.stdout.write(os.getcwd()); " "buf = sys.stdout.buffer; "
"buf.write(os.getcwd().encode()); "
"buf.flush(); "
"sys.exit(47)"], "sys.exit(47)"],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
**kwargs) **kwargs)
@ -382,7 +384,7 @@ class ProcessTestCase(BaseTestCase):
self.assertEqual(47, p.returncode) self.assertEqual(47, p.returncode)
normcase = os.path.normcase normcase = os.path.normcase
self.assertEqual(normcase(expected_cwd), self.assertEqual(normcase(expected_cwd),
normcase(p.stdout.read().decode("utf-8"))) normcase(p.stdout.read().decode()))
def test_cwd(self): def test_cwd(self):
# Check that cwd changes the cwd for the child process. # Check that cwd changes the cwd for the child process.