Skip to content

Commit

Permalink
Switch to OS-agnostic file comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
josephburkhart committed Sep 12, 2024
1 parent 763a262 commit b2a79d1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
import filecmp
import tempfile
from pathlib import Path

from coxeter import io
from coxeter.shapes import Polyhedron, ConvexPolyhedron
import pytest

from coxeter import io
from coxeter.shapes import ConvexPolyhedron, Polyhedron
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


EXPORT_FUNCS_BY_FILE_TYPE = {
"obj": io.to_obj,
Expand Down Expand Up @@ -80,7 +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 filecmp.cmp(control_file_path, test_file_path, shallow=False), (
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."
Expand Down

0 comments on commit b2a79d1

Please sign in to comment.