diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-03-03 14:07:21 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-03-03 14:07:21 (GMT) |
commit | ff45fedf61277a23650c79088372e7615599c5e7 (patch) | |
tree | 724bb9e6245b6ce1fd11145555728ca4fd6b51b8 /Lib/test/test_platform.py | |
parent | 1bc75c6ceebb3dd1488fce259fc05958e58c0c3c (diff) | |
download | cpython-ff45fedf61277a23650c79088372e7615599c5e7.zip cpython-ff45fedf61277a23650c79088372e7615599c5e7.tar.gz cpython-ff45fedf61277a23650c79088372e7615599c5e7.tar.bz2 |
Issue #11377: Fix quoting on Windows in test_platform
Diffstat (limited to 'Lib/test/test_platform.py')
-rw-r--r-- | Lib/test/test_platform.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 1ab0d9c..2b58ebf 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -244,14 +244,23 @@ class PlatformTest(unittest.TestCase): self.assertEqual(platform._parse_release_file(input), output) 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: hello = stdout.read().strip() stdout.close() self.assertEqual(hello, "Hello") - command = "'{}' -c 'import sys; data=sys.stdin.read(); exit(len(data))'".format(sys.executable) 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: stdout = stdin.write(data) ret = stdin.close() |