[pypy-svn] r72908 - pypy/branch/fix-win/pypy/interpreter/test
arigo at codespeak.net
arigo at codespeak.net
Fri Mar 26 16:52:23 CET 2010
Author: arigo
Date: Fri Mar 26 16:52:21 2010
New Revision: 72908
Modified:
pypy/branch/fix-win/pypy/interpreter/test/test_executioncontext.py
pypy/branch/fix-win/pypy/interpreter/test/test_zpy.py
Log:
Add quotes for Windows. Expected format:
""program" "arg1" "arg2""
Modified: pypy/branch/fix-win/pypy/interpreter/test/test_executioncontext.py
==============================================================================
--- pypy/branch/fix-win/pypy/interpreter/test/test_executioncontext.py (original)
+++ pypy/branch/fix-win/pypy/interpreter/test/test_executioncontext.py Fri Mar 26 16:52:21 2010
@@ -271,8 +271,8 @@
# would be called
import os, sys
print sys.executable, self.tmpfile
- if sys.platform == "win32": # quote? what's that?
- cmdformat = "%s %s"
+ if sys.platform == "win32":
+ cmdformat = '""%s" "%s""' # excellent! tons of "!
else:
cmdformat = "'%s' '%s'"
g = os.popen(cmdformat % (sys.executable, self.tmpfile), 'r')
Modified: pypy/branch/fix-win/pypy/interpreter/test/test_zpy.py
==============================================================================
--- pypy/branch/fix-win/pypy/interpreter/test/test_zpy.py (original)
+++ pypy/branch/fix-win/pypy/interpreter/test/test_zpy.py Fri Mar 26 16:52:21 2010
@@ -6,17 +6,23 @@
pypypath = py.path.local(pypy.__file__).dirpath("bin", "py.py")
+def cmdexec(s):
+ if sys.platform == 'win32':
+ s = '"%s"' % s # double double quotes
+ return py.process.cmdexec(s)
+
+
def test_executable():
"""Ensures sys.executable points to the py.py script"""
# TODO : watch out for spaces/special chars in pypypath
- output = py.process.cmdexec( '''"%s" "%s" -c "import sys;print sys.executable" ''' %
- (sys.executable, pypypath) )
+ output = cmdexec( '''"%s" "%s" -c "import sys;print sys.executable" ''' %
+ (sys.executable, pypypath) )
assert output.splitlines()[-1] == pypypath
def test_special_names():
"""Test the __name__ and __file__ special global names"""
cmd = "print __name__; print '__file__' in globals()"
- output = py.process.cmdexec( '''"%s" "%s" -c "%s" ''' %
+ output = cmdexec( '''"%s" "%s" -c "%s" ''' %
(sys.executable, pypypath, cmd) )
assert output.splitlines()[-2] == '__main__'
assert output.splitlines()[-1] == 'False'
@@ -26,7 +32,7 @@
tmpfile.write("print __name__; print __file__\n")
tmpfile.close()
- output = py.process.cmdexec( '''"%s" "%s" "%s" ''' %
+ output = cmdexec( '''"%s" "%s" "%s" ''' %
(sys.executable, pypypath, tmpfilepath) )
assert output.splitlines()[-2] == '__main__'
assert output.splitlines()[-1] == str(tmpfilepath)
@@ -34,17 +40,17 @@
def test_argv_command():
"""Some tests on argv"""
# test 1 : no arguments
- output = py.process.cmdexec( '''"%s" "%s" -c "import sys;print sys.argv" ''' %
+ output = cmdexec( '''"%s" "%s" -c "import sys;print sys.argv" ''' %
(sys.executable, pypypath) )
assert output.splitlines()[-1] == str(['-c'])
# test 2 : some arguments after
- output = py.process.cmdexec( '''"%s" "%s" -c "import sys;print sys.argv" hello''' %
+ output = cmdexec( '''"%s" "%s" -c "import sys;print sys.argv" hello''' %
(sys.executable, pypypath) )
assert output.splitlines()[-1] == str(['-c','hello'])
# test 3 : additionnal pypy parameters
- output = py.process.cmdexec( '''"%s" "%s" -O -c "import sys;print sys.argv" hello''' %
+ output = cmdexec( '''"%s" "%s" -O -c "import sys;print sys.argv" hello''' %
(sys.executable, pypypath) )
assert output.splitlines()[-1] == str(['-c','hello'])
@@ -59,17 +65,17 @@
tmpfile.close()
# test 1 : no arguments
- output = py.process.cmdexec( '''"%s" "%s" "%s" ''' %
+ output = cmdexec( '''"%s" "%s" "%s" ''' %
(sys.executable, pypypath, tmpfilepath) )
assert output.splitlines()[-1] == str([tmpfilepath])
# test 2 : some arguments after
- output = py.process.cmdexec( '''"%s" "%s" "%s" hello''' %
+ output = cmdexec( '''"%s" "%s" "%s" hello''' %
(sys.executable, pypypath, tmpfilepath) )
assert output.splitlines()[-1] == str([tmpfilepath,'hello'])
# test 3 : additionnal pypy parameters
- output = py.process.cmdexec( '''"%s" "%s" -O "%s" hello''' %
+ output = cmdexec( '''"%s" "%s" -O "%s" hello''' %
(sys.executable, pypypath, tmpfilepath) )
assert output.splitlines()[-1] == str([tmpfilepath,'hello'])
@@ -94,7 +100,7 @@
e = None
try:
- output = py.process.cmdexec( '''"%s" "%s" "%s" ''' %
+ output = cmdexec( '''"%s" "%s" "%s" ''' %
(sys.executable, pypypath, tmpfilepath) )
except py.process.cmdexec.Error, e:
pass
More information about the Pypy-commit
mailing list