Skip to content

Commit 033850e

Browse files
committed
add diff module tests
1 parent 1f72737 commit 033850e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/test_diff.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os
2+
3+
import pytest
4+
5+
from fdiff.diff import u_diff
6+
7+
ROBOTO_BEFORE_PATH = os.path.join("tests", "testfiles", "Roboto-Regular.subset1.ttf")
8+
ROBOTO_AFTER_PATH = os.path.join("tests", "testfiles", "Roboto-Regular.subset2.ttf")
9+
ROBOTO_UDIFF_EXPECTED_PATH = os.path.join("tests", "testfiles", "roboto_udiff_expected.txt")
10+
ROBOTO_UDIFF_COLOR_EXPECTED_PATH = os.path.join("tests", "testfiles", "roboto_udiff_color_expected.txt")
11+
12+
# Setup: define the expected diff text for unified diff
13+
with open(ROBOTO_UDIFF_EXPECTED_PATH, "r") as robo_udiff:
14+
ROBOTO_UDIFF_EXPECTED = robo_udiff.read()
15+
16+
# Setup: define the expected diff text for unified color diff
17+
with open(ROBOTO_UDIFF_COLOR_EXPECTED_PATH, "r") as robo_udiff_color:
18+
ROBOTO_UDIFF_COLOR_EXPECTED = robo_udiff_color.read()
19+
20+
21+
def test_unified_diff_default():
22+
res = u_diff(ROBOTO_BEFORE_PATH, ROBOTO_AFTER_PATH)
23+
res_string = "".join(res)
24+
assert res_string == ROBOTO_UDIFF_EXPECTED
25+
26+
27+

0 commit comments

Comments
 (0)