Skip to content

Commit 2b151a8

Browse files
committed
add color module tests
1 parent 72fb5c3 commit 2b151a8

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

tests/test_color.py

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from fdiff.color import color_unified_diff_line
2+
3+
import pytest
4+
5+
TEST_LINE_PLUS = "+ A line with a plus"
6+
TEST_LINE_MINUS = "- A line with a minus"
7+
TEST_LINE_AT = "@@ -69705,5 +30839,3 @@"
8+
TEST_LINE_PLUS3 = "+++ /Users/chris/Desktop/tests/dehinter-tests/Ubuntu-Regular-dehinted.ttf 2019-08-22T19:04:40.307911-04:00"
9+
TEST_LINE_MINUS3 = "--- /Users/chris/Desktop/tests/dehinter-tests/Ubuntu-Regular.ttf 2010-12-15T00:00:00-05:00"
10+
TEST_LINE_CONTEXT = " This is a line of context"
11+
12+
13+
def test_color_unified_diff_line_addition():
14+
line_response = color_unified_diff_line(TEST_LINE_PLUS)
15+
assert line_response.startswith("\033[32m") is True
16+
assert line_response.endswith("\033[0m") is True
17+
18+
19+
def test_color_unified_diff_line_removal():
20+
line_response = color_unified_diff_line(TEST_LINE_MINUS)
21+
assert line_response.startswith("\033[31m") is True
22+
assert line_response.endswith("\033[0m") is True
23+
24+
25+
def test_color_unified_diff_line_range():
26+
line_response = color_unified_diff_line(TEST_LINE_AT)
27+
assert line_response.startswith("\033[36m") is True
28+
assert line_response.endswith("\033[0m") is True
29+
30+
31+
def test_color_unified_diff_line_left_file():
32+
line_response = color_unified_diff_line(TEST_LINE_MINUS3)
33+
assert line_response.startswith("\033[31m") is True
34+
assert line_response.endswith("\033[0m") is True
35+
36+
37+
def test_color_unified_diff_line_right_file():
38+
line_response = color_unified_diff_line(TEST_LINE_PLUS3)
39+
assert line_response.startswith("\033[32m") is True
40+
assert line_response.endswith("\033[0m") is True
41+
42+
43+
def test_color_unified_diff_context_line():
44+
line_response = color_unified_diff_line(TEST_LINE_CONTEXT)
45+
assert line_response.startswith("\033") is False
46+
assert line_response.endswith("\033") is False
47+
assert line_response == TEST_LINE_CONTEXT

0 commit comments

Comments
 (0)