diff options
author | William Blevins <wblevins001@gmail.com> | 2016-09-20 16:07:30 -0400 |
---|---|---|
committer | William Blevins <wblevins001@gmail.com> | 2016-09-20 16:07:30 -0400 |
commit | de9188e444af59423350cfa7d7f122120d13be00 (patch) | |
tree | 03ded12777f86fbdae061bdc4199cabe766db2d6 /QMTest | |
parent | a866042810446ca47cf7479f25a005f0550a163f (diff) | |
download | scons-de9188e444af59423350cfa7d7f122120d13be00.tar.gz |
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 b0a456b9..d7b8d942 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 f878636a..9093cc99 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: |