[Python-checkins] r88724 - python/branches/py3k/Lib/test/test_platform.py

victor.stinner python-checkins at python.org
Thu Mar 3 15:07:22 CET 2011


Author: victor.stinner
Date: Thu Mar  3 15:07:21 2011
New Revision: 88724

Log:
Issue #11377: Fix quoting on Windows in test_platform

Modified:
   python/branches/py3k/Lib/test/test_platform.py

Modified: python/branches/py3k/Lib/test/test_platform.py
==============================================================================
--- python/branches/py3k/Lib/test/test_platform.py	(original)
+++ python/branches/py3k/Lib/test/test_platform.py	Thu Mar  3 15:07:21 2011
@@ -244,14 +244,23 @@
             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()


More information about the Python-checkins mailing list