Skip to content

Commit

Permalink
Add differ for unequal files
Browse files Browse the repository at this point in the history
  • Loading branch information
SorooshMani-NOAA committed Jul 31, 2024
1 parent 826b683 commit 52f10f7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from difflib import context_diff
from os import PathLike
from pathlib import Path
import re
Expand Down Expand Up @@ -76,6 +77,8 @@ def check_reference_directory(
del test_lines[line_index], reference_lines[line_index]

cwd = Path.cwd()
assert '\n'.join(test_lines) == '\n'.join(
reference_lines
), f'"{os.path.relpath(test_filename, cwd)}" != "{os.path.relpath(reference_filename, cwd)}"'
diff = context_diff(test_lines, reference_lines, lineterm='')
assert '\n'.join(test_lines) == '\n'.join(reference_lines), (
f'"{os.path.relpath(test_filename, cwd)}" != "{os.path.relpath(reference_filename, cwd)}"\n\n'
+ '\n'.join(diff)
)

0 comments on commit 52f10f7

Please sign in to comment.