Skip to content

Commit

Permalink
Check file equality by line
Browse files Browse the repository at this point in the history
  • Loading branch information
josephburkhart committed Sep 13, 2024
1 parent b2a79d1 commit 6e28a64
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def compare_text_files(file_path_1, file_path_2):
"""Check whether two text files have identical contents, ignoring different
newline characters."""
with open(file_path_1, "r") as file1, open(file_path_2, "r") as file2:
file1_contents, file2_contents = file1.read(), file2.read()
return file1_contents == file2_contents
file1_contents, file2_contents = file1.readlines(), file2.readlines()
assert file1_contents == file2_contents


EXPORT_FUNCS_BY_FILE_TYPE = {
Expand Down Expand Up @@ -86,11 +86,7 @@ def test_regression(file_type, export_func, shape_name):
test_file_path = Path(tempdir) / f"test_{shape_name}.{file_type}"
export_func(shape=shape, filename=test_file_path)

assert compare_text_files(control_file_path, test_file_path), (
f"During regression testing with the shape '{shape_name}' and "
f"file type '{file_type}', {control_file_path.name} and "
f"{test_file_path.name} were found to be not equivalent."
)
compare_text_files(control_file_path, test_file_path)


if __name__ == "__main__":
Expand Down

0 comments on commit 6e28a64

Please sign in to comment.