summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--QMTest/TestCommonTests.py13
-rw-r--r--src/engine/SCons/Util.py4
-rw-r--r--test/Configure/custom-tests.py4
-rw-r--r--test/ENV.py5
-rw-r--r--test/Interactive/shell.py4
-rw-r--r--test/SConscript/Return.py32
-rw-r--r--test/SConscript/SConscript.py4
-rw-r--r--test/SWIG/live.py8
-rw-r--r--test/TEMPFILEPREFIX.py3
-rw-r--r--test/builderrors.py3
10 files changed, 46 insertions, 34 deletions
diff --git a/QMTest/TestCommonTests.py b/QMTest/TestCommonTests.py
index 30b7d6a..7949cb8 100644
--- a/QMTest/TestCommonTests.py
+++ b/QMTest/TestCommonTests.py
@@ -168,10 +168,11 @@ class __init__TestCase(TestCommonTestCase):
os.chdir(run_env.workdir)
script = lstrip("""\
+ from __future__ import print_function
from TestCommon import TestCommon
tc = TestCommon(workdir='')
import os
- print os.getcwd()
+ print(os.getcwd())
""")
run_env.run(program=sys.executable, stdin=script)
stdout = run_env.stdout()[:-1]
@@ -2285,14 +2286,16 @@ class variables_TestCase(TestCommonTestCase):
'dll_suffix',
]
- script = "import TestCommon\n" + \
- '\n'.join([ "print TestCommon.%s\n" % v for v in variables ])
+ script = "from __future__ import print_function" + \
+ "import TestCommon\n" + \
+ '\n'.join([ "print(TestCommon.%s)\n" % v for v in variables ])
run_env.run(program=sys.executable, stdin=script)
stderr = run_env.stderr()
assert stderr == "", stderr
- script = "from TestCommon import *\n" + \
- '\n'.join([ "print %s" % v for v in variables ])
+ script = "from __future__ import print_function" + \
+ "from TestCommon import *\n" + \
+ '\n'.join([ "print(%s)" % v for v in variables ])
run_env.run(program=sys.executable, stdin=script)
stderr = run_env.stderr()
assert stderr == "", stderr
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index d6f18cc..018a776 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -1453,9 +1453,9 @@ def AddMethod(obj, function, name=None):
self.z = x + y
AddMethod(f, A, "add")
a.add(2, 4)
- print a.z
+ print(a.z)
AddMethod(lambda self, i: self.l[i], a, "listIndex")
- print a.listIndex(5)
+ print(a.listIndex(5))
"""
if name is None:
name = function.__name__
diff --git a/test/Configure/custom-tests.py b/test/Configure/custom-tests.py
index 503eb4e..7bb2366 100644
--- a/test/Configure/custom-tests.py
+++ b/test/Configure/custom-tests.py
@@ -49,8 +49,10 @@ runOK = compileOK
runFAIL = "int main() { return 1; }"
test.write('pyAct.py', """\
+from __future__ import print_function
+
import sys
-print sys.argv[1]
+print(sys.argv[1])
sys.exit(int(sys.argv[1]))
""")
diff --git a/test/ENV.py b/test/ENV.py
index dc97ec8..5cb2362 100644
--- a/test/ENV.py
+++ b/test/ENV.py
@@ -71,9 +71,10 @@ env['ENV']['FOO'] = foo
test.write('build.py',
r"""
+from __future__ import print_function
import os
-print 'LIST:', os.environ['LIST']
-print 'FOO:', os.environ['FOO']
+print('LIST:', os.environ['LIST'])
+print('FOO:', os.environ['FOO'])
""")
test.run()
diff --git a/test/Interactive/shell.py b/test/Interactive/shell.py
index 842a12e..40df86f 100644
--- a/test/Interactive/shell.py
+++ b/test/Interactive/shell.py
@@ -40,7 +40,9 @@ shell_command_py = test.workpath('shell_command.py')
_shell_command_py_ = '"%s"' % shell_command_py.replace('\\', '\\\\')
test.write(shell_command_py, """\
-print 'hello from shell_command.py'
+from __future__ import print_function
+
+print('hello from shell_command.py')
""")
test.write('SConstruct', """\
diff --git a/test/SConscript/Return.py b/test/SConscript/Return.py
index 997de9d..1f678af 100644
--- a/test/SConscript/Return.py
+++ b/test/SConscript/Return.py
@@ -39,50 +39,50 @@ x = SConscript('SConscript2')
y, z = SConscript('SConscript3')
a4, b4 = SConscript('SConscript4')
foo, bar = SConscript('SConscript5')
-print ("x =", x)
-print ("y =", y)
-print ("z =", z)
-print ("a4 =", a4)
-print ("b4 =", b4)
-print ("foo =", foo)
-print ("bar =", bar)
+print("x =", x)
+print("y =", y)
+print("z =", z)
+print("a4 =", a4)
+print("b4 =", b4)
+print("foo =", foo)
+print("bar =", bar)
""")
test.write('SConscript1', """\
-print ("line 1")
+print("line 1")
Return()
-print ("line 2")
+print("line 2")
""")
test.write('SConscript2', """\
-print ("line 3")
+print("line 3")
x = 7
Return('x')
-print ("line 4")
+print("line 4")
""")
test.write('SConscript3', """\
-print ("line 5")
+print("line 5")
y = 8
z = 9
Return('y z')
-print ("line 6")
+print("line 6")
""")
test.write('SConscript4', """\
a4 = 'aaa'
b4 = 'bbb'
-print ("line 7")
+print("line 7")
Return('a4', 'b4', stop=False)
b4 = 'b-after'
-print ("line 8")
+print("line 8")
""")
test.write('SConscript5', """\
foo = 'foo'
bar = 'bar'
Return(["foo", "bar"])
-print ("line 9")
+print("line 9")
""")
expect = """\
diff --git a/test/SConscript/SConscript.py b/test/SConscript/SConscript.py
index d1e09ce..2eeb211 100644
--- a/test/SConscript/SConscript.py
+++ b/test/SConscript/SConscript.py
@@ -37,7 +37,7 @@ import foo
assert foo.foo == 4
-print ("SConstruct", os.getcwd())
+print("SConstruct", os.getcwd())
SConscript('SConscript')
x1 = "SConstruct x1"
@@ -89,7 +89,7 @@ test.write('SConscript', """\
assert "os" not in globals()
import os
-print ("SConscript " + os.getcwd())
+print("SConscript " + os.getcwd())
""")
test.write('SConscript1', """
diff --git a/test/SWIG/live.py b/test/SWIG/live.py
index 5e95dc7..05971aa 100644
--- a/test/SWIG/live.py
+++ b/test/SWIG/live.py
@@ -131,8 +131,9 @@ test.run(arguments = ldmodule_prefix+'foo' + _dll)
test.must_not_exist(test.workpath('wrapper.out'))
test.run(program = python, stdin = """\
+from __future__ import print_function
import foo
-print foo.foo_string()
+print(foo.foo_string())
""", stdout="""\
This is foo.c!
""")
@@ -144,10 +145,11 @@ test.run(arguments = ldmodule_prefix+'bar' + _dll)
test.must_match('wrapper.out', "wrapper.py\n")
test.run(program = python, stdin = """\
+from __future__ import print_function
import foo
import bar
-print foo.foo_string()
-print bar.bar_string()
+print(foo.foo_string())
+print(bar.bar_string())
""", stdout="""\
This is foo.c!
This is bar.c!
diff --git a/test/TEMPFILEPREFIX.py b/test/TEMPFILEPREFIX.py
index 8e756af..f0743e6 100644
--- a/test/TEMPFILEPREFIX.py
+++ b/test/TEMPFILEPREFIX.py
@@ -38,8 +38,9 @@ test = TestSCons.TestSCons(match = TestSCons.match_re)
test.write('echo.py', """\
#!/usr/bin/env python
+from __future__ import print_function
import sys
-print sys.argv
+print(sys.argv)
""")
echo_py = test.workpath('echo.py')
diff --git a/test/builderrors.py b/test/builderrors.py
index 3d443bf..88015f1 100644
--- a/test/builderrors.py
+++ b/test/builderrors.py
@@ -171,6 +171,7 @@ test.must_not_contain_any_line(test.stderr(), ['Exception', 'Traceback'])
# Should not give traceback; the task error should get converted
# to a BuildError.
test.write('SConstruct', """
+from __future__ import print_function
import atexit
env = Environment()
@@ -182,7 +183,7 @@ env2.Install("target", "dir2/myFile")
def print_build_failures():
from SCons.Script import GetBuildFailures
for bf in GetBuildFailures():
- print bf.action
+ print(bf.action)
atexit.register(print_build_failures)
""")