diff options
| author | Ned Batchelder <ned@nedbatchelder.com> | 2014-05-02 20:24:09 -0400 | 
|---|---|---|
| committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-05-02 20:24:09 -0400 | 
| commit | 8ae2c4cdedec34c2e1a445e3f21df41e908a4d7f (patch) | |
| tree | 940c1224f43af4afc8f6d39b30f58941635bdd7c /tests/test_farm.py | |
| parent | 5d5c491b28f2f2dac07590cae3fce12635e47662 (diff) | |
| download | python-coveragepy-git-8ae2c4cdedec34c2e1a445e3f21df41e908a4d7f.tar.gz | |
Fix the error output for test_farm
Diffstat (limited to 'tests/test_farm.py')
| -rw-r--r-- | tests/test_farm.py | 16 | 
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/test_farm.py b/tests/test_farm.py index 65016b34..261ce4d0 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:  | 
