Commit e822ab01 authored by Benjamin Peterson's avatar Benjamin Peterson

fix test_popen when the path to python has spaces #7671

parent 0e207dff
...@@ -14,12 +14,10 @@ import os, sys ...@@ -14,12 +14,10 @@ import os, sys
# This results in Python being spawned and printing the sys.argv list. # This results in Python being spawned and printing the sys.argv list.
# We can then eval() the result of this, and see what each argv was. # We can then eval() the result of this, and see what each argv was.
python = sys.executable python = sys.executable
if ' ' in python:
python = '"' + python + '"' # quote embedded space for cmdline
class PopenTest(unittest.TestCase): class PopenTest(unittest.TestCase):
def _do_test_commandline(self, cmdline, expected): def _do_test_commandline(self, cmdline, expected):
cmd = '%s -c "import sys;print sys.argv" %s' % (python, cmdline) cmd = '%r -c "import sys;print sys.argv" %s' % (python, cmdline)
data = os.popen(cmd).read() data = os.popen(cmd).read()
got = eval(data)[1:] # strip off argv[0] got = eval(data)[1:] # strip off argv[0]
self.assertEqual(got, expected) self.assertEqual(got, expected)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment