Skip to content

Commit a7a572c

Browse files
committed
fix tests on Windows
1 parent 6750191 commit a7a572c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Lib/test/test_os/test_os.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2628,6 +2628,14 @@ def test_execve_env_concurrent_mutation_with_fspath(self):
26282628
# Prevent crash when mutating environment during parsing.
26292629
# Regression test for https://github.com/python/cpython/issues/143309.
26302630

2631+
if os.name == "nt":
2632+
# See https://github.com/python/cpython/pull/143314
2633+
# to understand why we cannot use spaces in strings
2634+
# when using subprocess and os.execve() on Windows.
2635+
message = 123456
2636+
else:
2637+
message = "hello from execve"
2638+
26312639
code = """
26322640
import os, sys
26332641
@@ -2644,13 +2652,13 @@ def __getitem__(self): return 1
26442652
def keys(self): return KEYS
26452653
def values(self): return VALUES
26462654
2647-
args = [sys.executable, '-c', 'print("hello from execve")']
2655+
args = [sys.executable, '-c', "print('{message}')"]
26482656
os.execve(args[0], args, MyEnv())
2649-
"""
2657+
""".format(message=message)
26502658

26512659
rc, out, _ = assert_python_ok('-c', code)
26522660
self.assertEqual(rc, 0)
2653-
self.assertIn(b"hello from execve", out)
2661+
self.assertIn(bytes(message, "ascii"), out)
26542662

26552663
@unittest.skipUnless(sys.platform == "win32", "Win32-specific test")
26562664
def test_execve_with_empty_path(self):

0 commit comments

Comments
 (0)