summaryrefslogtreecommitdiff
path: root/tests/test_farm.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2014-05-02 20:24:09 -0400
committerNed Batchelder <ned@nedbatchelder.com>2014-05-02 20:24:09 -0400
commit8ff1f85c7a7d69c1999502c5dc5df791ddd6fc91 (patch)
tree6e0687387d4ba200377e2477b8cdc1637e5ce36c /tests/test_farm.py
parent7457cce7cfffa4afd28311818f9f05c295ce2f81 (diff)
downloadpython-coveragepy-8ff1f85c7a7d69c1999502c5dc5df791ddd6fc91.tar.gz
Fix the error output for test_farm
Diffstat (limited to 'tests/test_farm.py')
-rw-r--r--tests/test_farm.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/test_farm.py b/tests/test_farm.py
index 65016b3..261ce4d 100644
--- a/tests/test_farm.py
+++ b/tests/test_farm.py
@@ -238,8 +238,10 @@ class FarmTestCase(object):
# guide for size comparison.
wrong_size = []
for f in diff_files:
- left = open(os.path.join(dir1, f), "rb").read()
- right = open(os.path.join(dir2, f), "rb").read()
+ with open(os.path.join(dir1, f), "rb") as fobj:
+ left = fobj.read()
+ with open(os.path.join(dir2, f), "rb") as fobj:
+ right = fobj.read()
size_l, size_r = len(left), len(right)
big, little = max(size_l, size_r), min(size_l, size_r)
if (big - little) / float(little) > size_within/100.0:
@@ -256,14 +258,18 @@ class FarmTestCase(object):
# ourselves.
text_diff = []
for f in diff_files:
- left = open(os.path.join(dir1, f), "rU").read()
- right = open(os.path.join(dir2, f), "rU").read()
+ with open(os.path.join(dir1, f), "rU") as fobj:
+ left = fobj.read()
+ with open(os.path.join(dir2, f), "rU") as fobj:
+ right = fobj.read()
if scrubs:
left = self._scrub(left, scrubs)
right = self._scrub(right, scrubs)
if left != right:
text_diff.append(f)
- print("".join(list(difflib.Differ().compare(left, right))))
+ left = left.splitlines()
+ right = right.splitlines()
+ print("\n".join(difflib.Differ().compare(left, right)))
assert not text_diff, "Files differ: %s" % text_diff
if not left_extra: