diff options
-rw-r--r-- | QMTest/TestCmd.py | 19 | ||||
-rw-r--r-- | QMTest/TestCommon.py | 2 | ||||
-rw-r--r-- | src/engine/SCons/Tool/swig.py | 2 | ||||
-rw-r--r-- | test/AR/AR.py | 4 | ||||
-rw-r--r-- | test/AR/ARCOM.py | 2 | ||||
-rw-r--r-- | test/AR/ARCOMSTR.py | 2 | ||||
-rw-r--r-- | test/AR/ARFLAGS.py | 4 |
7 files changed, 26 insertions, 9 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index b0a456b..d7b8d94 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -328,12 +328,27 @@ __all__ = [ 'match_re_dotall', 'python', '_python_', - 'TestCmd' + 'TestCmd', + 'to_bytes', + 'to_str', ] def is_List(e): return isinstance(e, (list, UserList)) +def to_bytes (s): + if isinstance (s, bytes) or bytes is str: + return s + else: + return bytes (s, 'utf-8') + +def to_str (s): + if bytes is str: + return s + elif not is_String(s): + return str (s, 'utf-8') + return s + try: eval('unicode') except NameError: @@ -513,6 +528,8 @@ def simple_diff(a, b, fromfile='', tofile='', (diff -c) and difflib.unified_diff (diff -u) but which prints output like the simple, unadorned 'diff" command. """ + a = [to_str(q) for q in a] + b = [to_str(q) for q in b] sm = difflib.SequenceMatcher(None, a, b) def comma(x1, x2): return x1+1 == x2 and str(x2) or '%s,%s' % (x1+1, x2) diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py index f878636..9093cc9 100644 --- a/QMTest/TestCommon.py +++ b/QMTest/TestCommon.py @@ -479,7 +479,7 @@ class TestCommon(TestCmd): if not match: match = self.match try: - self.fail_test(not match(file_contents, expect)) + self.fail_test(not match(to_str(file_contents), to_str(expect))) except KeyboardInterrupt: raise except: diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py index fa86174..9935de8 100644 --- a/src/engine/SCons/Tool/swig.py +++ b/src/engine/SCons/Tool/swig.py @@ -143,7 +143,7 @@ def _get_swig_version(env, swig): # MAYBE: out = SCons.Util.to_str (pipe.stdout.read()) out = pipe.stdout.read() - match = re.search(r'SWIG Version\s+(\S+).*', out, re.MULTILINE) + match = re.search(b'SWIG Version\s+(\S+).*', out, re.MULTILINE) if match: if verbose: print("Version is:%s"%match.group(1)) return match.group(1) diff --git a/test/AR/AR.py b/test/AR/AR.py index 8fb8073..573f2d9 100644 --- a/test/AR/AR.py +++ b/test/AR/AR.py @@ -36,7 +36,7 @@ test = TestSCons.TestSCons() test.write("wrapper.py", """import os import sys -open('%s', 'wb').write("wrapper.py\\n") +open('%s', 'wb').write(b"wrapper.py\\n") os.system(" ".join(sys.argv[1:])) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -100,7 +100,7 @@ test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.fail_test(test.read('wrapper.out') != b"wrapper.py\n") test.pass_test() diff --git a/test/AR/ARCOM.py b/test/AR/ARCOM.py index f26ced6..bf2830e 100644 --- a/test/AR/ARCOM.py +++ b/test/AR/ARCOM.py @@ -41,7 +41,7 @@ import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*ar*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*ar*/\\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/AR/ARCOMSTR.py b/test/AR/ARCOMSTR.py index 4c0bb85..1b1a9fb 100644 --- a/test/AR/ARCOMSTR.py +++ b/test/AR/ARCOMSTR.py @@ -42,7 +42,7 @@ import sys outfile = open(sys.argv[1], 'wb') for f in sys.argv[2:]: infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != '/*ar*/\\n']: + for l in [l for l in infile.readlines() if l != b'/*ar*/\\n']: outfile.write(l) sys.exit(0) """) diff --git a/test/AR/ARFLAGS.py b/test/AR/ARFLAGS.py index be4e8bd..fad9c19 100644 --- a/test/AR/ARFLAGS.py +++ b/test/AR/ARFLAGS.py @@ -36,7 +36,7 @@ test = TestSCons.TestSCons() test.write("wrapper.py", """import os import sys -open('%s', 'wb').write("wrapper.py\\n") +open('%s', 'wb').write(b"wrapper.py\\n") os.system(" ".join(sys.argv[1:])) """ % test.workpath('wrapper.out').replace('\\', '\\\\')) @@ -99,7 +99,7 @@ test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall) -test.fail_test(test.read('wrapper.out') != "wrapper.py\n") +test.fail_test(test.read('wrapper.out') != b"wrapper.py\n") test.pass_test() |