Skip to content

Commit 0d4fa81

Browse files
committed
fix approach to testing of top two lines of unified diff that include local platform defined timezone strings
1 parent 033850e commit 0d4fa81

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tests/test_diff.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,21 @@
2121
def test_unified_diff_default():
2222
res = u_diff(ROBOTO_BEFORE_PATH, ROBOTO_AFTER_PATH)
2323
res_string = "".join(res)
24-
assert res_string == ROBOTO_UDIFF_EXPECTED
24+
res_string_list = res_string.split("\n")
25+
expected_string_list = ROBOTO_UDIFF_EXPECTED.split("\n")
26+
27+
# have to handle the tests for the top two file path lines
28+
# differently than the rest of the comparisons because
29+
# the time is defined using local platform settings
30+
# which makes tests fail on remote CI testing services vs.
31+
# my local testing platform...
32+
for x, line in enumerate(res_string_list):
33+
# treat top two lines of the diff as comparison of first 10 chars only
34+
if x in (0, 1):
35+
assert line[0:9] == expected_string_list[x][0:9]
36+
else:
37+
assert line == expected_string_list[x]
38+
2539

2640

2741

0 commit comments

Comments
 (0)