diff options
| author | Rusty Wagner <rusty@vector35.com> | 2020-06-15 20:06:31 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2020-06-15 20:06:31 -0400 |
| commit | 75588da11bc29b00cac46c494ea389ac87b49778 (patch) | |
| tree | fb6965447617a72a00753e6d80f7fda2311b4478 /suite/testcommon.py | |
| parent | e587c9f6e532d3e5fedee8504aeb0c94e3604c91 (diff) | |
Fix Python 3 unit tests
Diffstat (limited to 'suite/testcommon.py')
| -rw-r--r-- | suite/testcommon.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/suite/testcommon.py b/suite/testcommon.py index ce1039f1..25a8b4a5 100644 --- a/suite/testcommon.py +++ b/suite/testcommon.py @@ -54,6 +54,11 @@ def fixSet(string): return string +def fixStrRepr(string): + # Python 2 and Python 3 represent Unicode character reprs differently + return string.replace(b"\xe2\x80\xa6".decode("utf8"), "\\xe2\\x80\\xa6") + + def get_file_list(test_store_rel): test_store = os.path.join(os.path.dirname(__file__), test_store_rel) all_files = [] @@ -199,7 +204,7 @@ class BinaryViewTestBuilder(Builder): prefixList.append(str(contents)) else: prefixList.append(i) - retinfo.append("Function: {:x} Instruction: {:x} Prefix operands: {}".format(func.start, ins.address, str(prefixList))) + retinfo.append("Function: {:x} Instruction: {:x} Prefix operands: {}".format(func.start, ins.address, fixStrRepr(str(prefixList)))) postfixList = [] for i in ins.postfix_operands: @@ -210,7 +215,7 @@ class BinaryViewTestBuilder(Builder): postfixList.append(str(contents)) else: postfixList.append(i) - retinfo.append("Function: {:x} Instruction: {:x} Postfix operands: {}".format(func.start, ins.address, str(postfixList))) + retinfo.append("Function: {:x} Instruction: {:x} Postfix operands: {}".format(func.start, ins.address, fixStrRepr(str(postfixList)))) retinfo.append("Function: {:x} Instruction: {:x} SSA form: {}".format(func.start, ins.address, str(ins.ssa_form))) retinfo.append("Function: {:x} Instruction: {:x} Non-SSA form: {}".format(func.start, ins.address, str(ins.non_ssa_form))) @@ -264,7 +269,7 @@ class BinaryViewTestBuilder(Builder): prefixList.append(str(contents)) else: prefixList.append(str(i)) - retinfo.append("Function: {:x} Instruction: {:x} Prefix operands: {}".format(func.start, ins.address, str(sorted(prefixList)))) + retinfo.append("Function: {:x} Instruction: {:x} Prefix operands: {}".format(func.start, ins.address, fixStrRepr(str(sorted(prefixList))))) postfixList = [] for i in ins.postfix_operands: if isinstance(i, float) and 'e' in str(i): @@ -279,7 +284,7 @@ class BinaryViewTestBuilder(Builder): else: postfixList.append(str(i)) - retinfo.append("Function: {:x} Instruction: {:x} Postfix operands: {}".format(func.start, ins.address, str(sorted(postfixList)))) + retinfo.append("Function: {:x} Instruction: {:x} Postfix operands: {}".format(func.start, ins.address, fixStrRepr(str(sorted(postfixList))))) retinfo.append("Function: {:x} Instruction: {:x} SSA form: {}".format(func.start, ins.address, str(ins.ssa_form))) retinfo.append("Function: {:x} Instruction: {:x} Non-SSA form: {}".format(func.start, ins.address, str(ins.non_ssa_form))) return fixOutput(retinfo) |
