diff options
author | William Blevins <wblevins001@gmail.com> | 2016-09-20 20:07:30 (GMT) |
---|---|---|
committer | William Blevins <wblevins001@gmail.com> | 2016-09-20 20:07:30 (GMT) |
commit | 0e2a4161264e7bac8368b8132b368796c880e30e (patch) | |
tree | 03ded12777f86fbdae061bdc4199cabe766db2d6 /QMTest | |
parent | 226c34a47471c5c27bc9a0c262edd62d713acc81 (diff) | |
download | SCons-0e2a4161264e7bac8368b8132b368796c880e30e.zip SCons-0e2a4161264e7bac8368b8132b368796c880e30e.tar.gz SCons-0e2a4161264e7bac8368b8132b368796c880e30e.tar.bz2 |
Fixing QMTest str and bytes issues.
Diffstat (limited to 'QMTest')
-rw-r--r-- | QMTest/TestCmd.py | 19 | ||||
-rw-r--r-- | QMTest/TestCommon.py | 2 |
2 files changed, 19 insertions, 2 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: |