mirror of
https://github.com/python/cpython.git
synced 2025-09-01 14:38:00 +00:00
Issue #11377: Fix quoting on Windows in test_platform
This commit is contained in:
parent
1bc75c6cee
commit
ff45fedf61
1 changed files with 11 additions and 2 deletions
|
@ -244,14 +244,23 @@ class PlatformTest(unittest.TestCase):
|
||||||
self.assertEqual(platform._parse_release_file(input), output)
|
self.assertEqual(platform._parse_release_file(input), output)
|
||||||
|
|
||||||
def test_popen(self):
|
def test_popen(self):
|
||||||
command = "'{}' -c 'print(\"Hello\")'".format(sys.executable)
|
mswindows = (sys.platform == "win32")
|
||||||
|
|
||||||
|
if mswindows:
|
||||||
|
command = '"{}" -c "print(\'Hello\')"'.format(sys.executable)
|
||||||
|
else:
|
||||||
|
command = "'{}' -c 'print(\"Hello\")'".format(sys.executable)
|
||||||
with platform.popen(command) as stdout:
|
with platform.popen(command) as stdout:
|
||||||
hello = stdout.read().strip()
|
hello = stdout.read().strip()
|
||||||
stdout.close()
|
stdout.close()
|
||||||
self.assertEqual(hello, "Hello")
|
self.assertEqual(hello, "Hello")
|
||||||
|
|
||||||
command = "'{}' -c 'import sys; data=sys.stdin.read(); exit(len(data))'".format(sys.executable)
|
|
||||||
data = 'plop'
|
data = 'plop'
|
||||||
|
if mswindows:
|
||||||
|
command = '"{}" -c "import sys; data=sys.stdin.read(); exit(len(data))"'
|
||||||
|
else:
|
||||||
|
command = "'{}' -c 'import sys; data=sys.stdin.read(); exit(len(data))'"
|
||||||
|
command = command.format(sys.executable)
|
||||||
with platform.popen(command, 'w') as stdin:
|
with platform.popen(command, 'w') as stdin:
|
||||||
stdout = stdin.write(data)
|
stdout = stdin.write(data)
|
||||||
ret = stdin.close()
|
ret = stdin.close()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue