(self, actual, expected)
| 753 | self.fail_test(1) |
| 754 | |
| 755 | def maybe_do_diff(self, actual, expected): |
| 756 | if os.environ.get("DO_DIFF"): |
| 757 | e = tempfile.mktemp("expected") |
| 758 | a = tempfile.mktemp("actual") |
| 759 | f = open(e, "w") |
| 760 | f.write(expected) |
| 761 | f.close() |
| 762 | f = open(a, "w") |
| 763 | f.write(actual) |
| 764 | f.close() |
| 765 | print("DIFFERENCE") |
| 766 | # Current diff should return 1 to indicate 'different input files' |
| 767 | # but some older diff versions may return 0 and depending on the |
| 768 | # exact Python/OS platform version, os.system() call may gobble up |
| 769 | # the external process's return code and return 0 itself. |
| 770 | if os.system('diff -u "%s" "%s"' % (e, a)) not in [0, 1]: |
| 771 | print('Unable to compute difference: diff -u "%s" "%s"' % (e, a |
| 772 | )) |
| 773 | os.unlink(e) |
| 774 | os.unlink(a) |
| 775 | else: |
| 776 | print("Set environmental variable 'DO_DIFF' to examine the " |
| 777 | "difference.") |
| 778 | |
| 779 | # Internal methods. |
| 780 | def adjust_lib_name(self, name): |
no test coverage detected