diff options
| author | Bob Halley <halley@dnspython.org> | 2020-06-15 16:52:46 -0700 |
|---|---|---|
| committer | Bob Halley <halley@dnspython.org> | 2020-06-15 16:52:53 -0700 |
| commit | 853c2bacb1ff7e7b81d4948809ca810008d44839 (patch) | |
| tree | a04fed8b3ec5b4c6ef0e42a2f588767f9fbac910 /tests/test_zone.py | |
| parent | 41de1f3cc0c1a0472b2dad2525844eb40b868067 (diff) | |
| download | dnspython-853c2bacb1ff7e7b81d4948809ca810008d44839.tar.gz | |
print out more if file comparison fails
Diffstat (limited to 'tests/test_zone.py')
| -rw-r--r-- | tests/test_zone.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_zone.py b/tests/test_zone.py index 3f77f4a..4f6b58c 100644 --- a/tests/test_zone.py +++ b/tests/test_zone.py @@ -17,8 +17,10 @@ # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. from io import BytesIO, StringIO +import difflib import filecmp import os +import sys import unittest from typing import cast @@ -167,6 +169,12 @@ def make_xfr(zone): add_rdataset(msg, soa_name, soa) return [msg] +def print_differences(a_name, b_name): + with open(a_name, 'r') as a: + with open(b_name, 'r') as b: + differ = difflib.Differ() + sys.stdout.writelines(differ.compare(a.readlines(), b.readlines())) + class ZoneTestCase(unittest.TestCase): def testFromFile1(self): # type: () -> None @@ -176,6 +184,9 @@ class ZoneTestCase(unittest.TestCase): z.to_file(here('example1.out'), nl=b'\x0a') ok = filecmp.cmp(here('example1.out'), here('example1.good')) + if not ok: + print_differences(here('example1.out'), + here('example1.good')) finally: if not _keep_output: os.unlink(here('example1.out')) |
