diff options
author | Stefan Zimmermann <zimmermann.code@gmail.com> | 2014-03-31 15:13:02 (GMT) |
---|---|---|
committer | Stefan Zimmermann <zimmermann.code@gmail.com> | 2014-03-31 15:13:02 (GMT) |
commit | 1a1a11122ad28df19d305af879ba79a2b08ce7d4 (patch) | |
tree | 4464eb544fe0cc698ea4d1c5789e19770b83cd6f /QMTest | |
parent | 9f36c5b899b8d2d54cae8d3da76b01308c144ed6 (diff) | |
download | SCons-1a1a11122ad28df19d305af879ba79a2b08ce7d4.zip SCons-1a1a11122ad28df19d305af879ba79a2b08ce7d4.tar.gz SCons-1a1a11122ad28df19d305af879ba79a2b08ce7d4.tar.bz2 |
Made former 2to3 changes Python 2.7 compatible (or removed unneeded changes).
Diffstat (limited to 'QMTest')
-rw-r--r-- | QMTest/TestCmd.py | 7 | ||||
-rw-r--r-- | QMTest/TestCmdTests.py | 109 | ||||
-rw-r--r-- | QMTest/TestCommon.py | 1 | ||||
-rw-r--r-- | QMTest/TestSCons.py | 12 | ||||
-rw-r--r-- | QMTest/TestSConsign.py | 1 | ||||
-rw-r--r-- | QMTest/scons_tdb.py | 4 |
6 files changed, 72 insertions, 62 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 26401ad..488d940 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -1,4 +1,3 @@ -from __future__ import print_function """ TestCmd.py: a testing framework for commands and scripts. @@ -286,7 +285,7 @@ version. # PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, # AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - +from __future__ import division, print_function __author__ = "Steven Knight <knight at baldmt dot com>" __revision__ = "TestCmd.py 1.3.D001 2010/06/03 12:58:27 knight" @@ -356,7 +355,7 @@ except NameError: return isinstance(e, (str, UserString)) else: def is_String(e): - return isinstance(e, (str, UserString)) + return isinstance(e, (str, unicode, UserString)) tempfile.template = 'testcmd.' if os.name in ('posix', 'nt'): @@ -951,7 +950,7 @@ class TestCmd(object): condition = self.condition if self._preserve[condition]: for dir in self._dirlist: - print("Preserved directory " + dir + "\n", end=' ') + print("Preserved directory " + dir + "\n") else: list = self._dirlist[:] list.reverse() diff --git a/QMTest/TestCmdTests.py b/QMTest/TestCmdTests.py index 96e0cbf..6611590 100644 --- a/QMTest/TestCmdTests.py +++ b/QMTest/TestCmdTests.py @@ -19,6 +19,8 @@ AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. """ +from six import PY3 + __author__ = "Steven Knight <knight at baldmt dot com>" __revision__ = "TestCmdTests.py 1.3.D001 2010/06/03 12:58:27 knight" @@ -26,13 +28,20 @@ import os import shutil import signal import stat -import io +if PY3: + from io import StringIO +else: + from StringIO import StringIO import sys import tempfile import time import types import unittest -import collections +if PY3: + from collections import UserList +else: + from UserList import UserList + # Strip the current directory so we get the right TestCmd.py module. sys.path = sys.path[1:] @@ -1032,14 +1041,14 @@ class match_exact_TestCase(TestCmdTestCase): assert test.match_exact("abcde\n", "abcde\n") assert not test.match_exact(["12345\n", "abcde\n"], ["1[0-9]*5\n", "a.*e\n"]) assert test.match_exact(["12345\n", "abcde\n"], ["12345\n", "abcde\n"]) - assert not test.match_exact(collections.UserList(["12345\n", "abcde\n"]), + assert not test.match_exact(UserList(["12345\n", "abcde\n"]), ["1[0-9]*5\n", "a.*e\n"]) - assert test.match_exact(collections.UserList(["12345\n", "abcde\n"]), + assert test.match_exact(UserList(["12345\n", "abcde\n"]), ["12345\n", "abcde\n"]) assert not test.match_exact(["12345\n", "abcde\n"], - collections.UserList(["1[0-9]*5\n", "a.*e\n"])) + UserList(["1[0-9]*5\n", "a.*e\n"])) assert test.match_exact(["12345\n", "abcde\n"], - collections.UserList(["12345\n", "abcde\n"])) + UserList(["12345\n", "abcde\n"])) assert not test.match_exact("12345\nabcde\n", "1[0-9]*5\na.*e\n") assert test.match_exact("12345\nabcde\n", "12345\nabcde\n") lines = ["vwxyz\n", "67890\n"] @@ -1098,28 +1107,28 @@ sys.exit(0) ["1.*j\n"]) assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"], ["12345\n", "abcde\n", "fghij\n"]) - assert test.match_re_dotall(collections.UserList(["12345\n", - "abcde\n", - "fghij\n"]), + assert test.match_re_dotall(UserList(["12345\n", + "abcde\n", + "fghij\n"]), ["1[0-9]*5\n", "a.*e\n", "f.*j\n"]) - assert test.match_re_dotall(collections.UserList(["12345\n", - "abcde\n", - "fghij\n"]), + assert test.match_re_dotall(UserList(["12345\n", + "abcde\n", + "fghij\n"]), ["1.*j\n"]) - assert test.match_re_dotall(collections.UserList(["12345\n", - "abcde\n", - "fghij\n"]), + assert test.match_re_dotall(UserList(["12345\n", + "abcde\n", + "fghij\n"]), ["12345\n", "abcde\n", "fghij\n"]) assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"], - collections.UserList(["1[0-9]*5\n", - "a.*e\n", - "f.*j\n"])) + UserList(["1[0-9]*5\n", + "a.*e\n", + "f.*j\n"])) assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"], - collections.UserList(["1.*j\n"])) + UserList(["1.*j\n"])) assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"], - collections.UserList(["12345\n", - "abcde\n", - "fghij\n"])) + UserList(["12345\n", + "abcde\n", + "fghij\n"])) assert test.match_re_dotall("12345\nabcde\nfghij\n", "1[0-9]*5\na.*e\nf.*j\n") assert test.match_re_dotall("12345\nabcde\nfghij\n", "1.*j\n") @@ -1176,14 +1185,14 @@ sys.exit(0) assert test.match_re("abcde\n", "abcde\n") assert test.match_re(["12345\n", "abcde\n"], ["1[0-9]*5\n", "a.*e\n"]) assert test.match_re(["12345\n", "abcde\n"], ["12345\n", "abcde\n"]) - assert test.match_re(collections.UserList(["12345\n", "abcde\n"]), + assert test.match_re(UserList(["12345\n", "abcde\n"]), ["1[0-9]*5\n", "a.*e\n"]) - assert test.match_re(collections.UserList(["12345\n", "abcde\n"]), + assert test.match_re(UserList(["12345\n", "abcde\n"]), ["12345\n", "abcde\n"]) assert test.match_re(["12345\n", "abcde\n"], - collections.UserList(["1[0-9]*5\n", "a.*e\n"])) + UserList(["1[0-9]*5\n", "a.*e\n"])) assert test.match_re(["12345\n", "abcde\n"], - collections.UserList(["12345\n", "abcde\n"])) + UserList(["12345\n", "abcde\n"])) assert test.match_re("12345\nabcde\n", "1[0-9]*5\na.*e\n") assert test.match_re("12345\nabcde\n", "12345\nabcde\n") lines = ["vwxyz\n", "67890\n"] @@ -1463,7 +1472,7 @@ class preserve_TestCase(TestCmdTestCase): def test_preserve(self): """Test preserve()""" def cleanup_test(test, cond=None, stdout=""): - io = io.StringIO() + io = StringIO() save = sys.stdout sys.stdout = io try: @@ -1603,7 +1612,7 @@ class read_TestCase(TestCmdTestCase): _file_matches(wdir_foo_file3, test.read(['foo', 'file3']), "Test\nfile\n#3.\n") _file_matches(wdir_foo_file3, - test.read(collections.UserList(['foo', 'file3'])), + test.read(UserList(['foo', 'file3'])), "Test\nfile\n#3.\n") _file_matches(wdir_file4, test.read('file4', mode = 'r'), "Test\nfile\n#4.\n") @@ -1862,8 +1871,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 1) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() test.run(arguments = ['arg1 arg2']) o = sys.stdout.getvalue() @@ -1876,8 +1885,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 1) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() testx.run(arguments = ['arg1 arg2']) expect = '"%s" "arg1 arg2"\n' % t.scriptx_path @@ -1913,8 +1922,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 2) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() test.run(arguments = ['arg1 arg2']) @@ -1934,8 +1943,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 2) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() testx.run(arguments = ['arg1 arg2']) @@ -1958,8 +1967,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 2) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() test.run(arguments = ['arg1 arg2']) @@ -1978,8 +1987,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 3) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() test.run(arguments = ['arg1 arg2']) @@ -2002,8 +2011,8 @@ class run_verbose_TestCase(TestCmdTestCase): interpreter = 'python', workdir = '') - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() test.run(arguments = ['arg1 arg2']) @@ -2022,8 +2031,8 @@ class run_verbose_TestCase(TestCmdTestCase): testx = TestCmd.TestCmd(program = t.scriptx, workdir = '') - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() testx.run(arguments = ['arg1 arg2']) @@ -2048,8 +2057,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 1) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() test.run(arguments = ['arg1 arg2']) o = sys.stdout.getvalue() @@ -2062,8 +2071,8 @@ class run_verbose_TestCase(TestCmdTestCase): workdir = '', verbose = 1) - sys.stdout = io.StringIO() - sys.stderr = io.StringIO() + sys.stdout = StringIO() + sys.stderr = StringIO() testx.run(arguments = ['arg1 arg2']) expect = '"%s" "arg1 arg2"\n' % t.scriptx_path @@ -2769,7 +2778,7 @@ class subdir_TestCase(TestCmdTestCase): assert test.subdir(['foo', 'fail']) == 0 assert test.subdir(['sub', 'dir', 'ectory'], 'sub') == 1 assert test.subdir('one', - collections.UserList(['one', 'two']), + UserList(['one', 'two']), ['one', 'two', 'three']) == 3 assert os.path.isdir(test.workpath('foo')) assert os.path.isdir(test.workpath('bar')) @@ -2962,7 +2971,7 @@ class unlink_TestCase(TestCmdTestCase): test.unlink(['foo', 'file3a']) assert not os.path.exists(wdir_foo_file3a) - test.unlink(collections.UserList(['foo', 'file3b'])) + test.unlink(UserList(['foo', 'file3b'])) assert not os.path.exists(wdir_foo_file3b) test.unlink([test.workdir, 'foo', 'file4']) diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py index 5a397ff..f1a7407 100644 --- a/QMTest/TestCommon.py +++ b/QMTest/TestCommon.py @@ -90,6 +90,7 @@ The TestCommon module also provides the following variables # PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, # AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. +from __future__ import print_function __author__ = "Steven Knight <knight at baldmt dot com>" __revision__ = "TestCommon.py 1.3.D001 2010/06/03 12:58:27 knight" diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 72624e6..5d0b4c6 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -13,7 +13,7 @@ attributes defined in this subclass. """ # __COPYRIGHT__ - +from __future__ import division, print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -721,7 +721,7 @@ class TestSCons(TestCommon): home = os.path.normpath('%s/..'%jar) if os.path.isdir(home): return home - print(("Could not determine JAVA_HOME: %s is not a directory" % home)) + print("Could not determine JAVA_HOME: %s is not a directory" % home) self.fail_test() def java_where_jar(self, version=None): @@ -1013,7 +1013,7 @@ SConscript( sconscript ) raise NoMatch(lastEnd) return m.end() + lastEnd try: - #print len(os.linesep) + #print(len(os.linesep)) ls = os.linesep nols = "(" for i in range(len(ls)): @@ -1241,7 +1241,7 @@ class TimeSCons(TestSCons): self.variables = kw.get('variables') default_calibrate_variables = [] if self.variables is not None: - for variable, value in list(self.variables.items()): + for variable, value in self.variables.items(): value = os.environ.get(variable, value) try: value = int(value) @@ -1297,7 +1297,7 @@ class TimeSCons(TestSCons): """ if 'options' not in kw and self.variables: options = [] - for variable, value in list(self.variables.items()): + for variable, value in self.variables.items(): options.append('%s=%s' % (variable, value)) kw['options'] = ' '.join(options) if self.calibrate: @@ -1323,7 +1323,7 @@ class TimeSCons(TestSCons): self.elapsed_time(), "seconds", sort=0) - for name, args in list(stats.items()): + for name, args in stats.items(): self.trace(name, trace, **args) def uptime(self): diff --git a/QMTest/TestSConsign.py b/QMTest/TestSConsign.py index 665059c..a48b648 100644 --- a/QMTest/TestSConsign.py +++ b/QMTest/TestSConsign.py @@ -1,4 +1,5 @@ # __COPYRIGHT__ +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/QMTest/scons_tdb.py b/QMTest/scons_tdb.py index 845e99c..76c7fe1 100644 --- a/QMTest/scons_tdb.py +++ b/QMTest/scons_tdb.py @@ -20,7 +20,7 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - +from __future__ import division, print_function """ QMTest classes to support SCons' testing and Aegis-inspired workflow. @@ -92,7 +92,7 @@ def get_explicit_arguments(e): # Determine which subset of the 'arguments' have been set # explicitly. explicit_arguments = {} - for name, field in list(arguments.items()): + for name, field in arguments.items(): # Do not record computed fields. if field.IsComputed(): continue |