From: Victor Stinner Date: Thu, 3 Mar 2011 14:07:21 +0000 (+0000) Subject: Issue #11377: Fix quoting on Windows in test_platform X-Git-Tag: v3.3.0a1~3003 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ff45fedf61277a23650c79088372e7615599c5e7;p=python Issue #11377: Fix quoting on Windows in test_platform --- diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 1ab0d9caa5..2b58ebf1cc 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()