Skip to content

Commit

Permalink
Better test debugging by first comparing the actual file content
Browse files Browse the repository at this point in the history
This slightly slows down the test, but makes test failures much more friendly to debug, which is worth it.
  • Loading branch information
Eric-Arellano committed Jun 13, 2019
1 parent 930ba39 commit 98a237c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1384,8 +1384,13 @@ def explode_pex(path):
for pex1, pex2 in itertools.combinations(pexes, r=2):
# First compare file-by-file for easier debugging.
for member1, member2 in zip(pex_members[pex1], pex_members[pex2]):
# Check that each file has the same content.
with open(member1, "rb") as f1, open(member2, "rb") as f2:
assert list(f1.readlines()) == list(f2.readlines()), \
"{} and {} have different content.".format(member1, member2)
# Check that the entire file is equal, including metadata.
assert filecmp.cmp(member1, member2, shallow=False)
# Then compare the original .pex files. This is the assertion we truly care about.
# Finally, check that the .pex files are byte-for-byte identical.
assert filecmp.cmp(pex1, pex2, shallow=False)


Expand Down

0 comments on commit 98a237c

Please sign in to comment.