Skip to content

Commit 80ff433

Browse files
committed
add multi glyph tests for direction sub-command
1 parent e5bd40e commit 80ff433

File tree

1 file changed

+64
-6
lines changed

1 file changed

+64
-6
lines changed

tests/test_direction.py

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ def test_direction_run_fail_invalid_glyphname(capsys):
5656
assert "Failed to open glyph" in captured.err
5757

5858

59-
def test_path_run_single_glyph_non_composite_no_contours_default(capsys, monkeypatch):
59+
def test_direction_run_single_glyph_non_composite_no_contours_default(
60+
capsys, monkeypatch
61+
):
6062
def mock_isatty():
6163
return True
6264

@@ -72,7 +74,9 @@ def mock_isatty():
7274
assert "[ \x1b[1;36m.notdef\x1b[0m ]: no contours" in captured.out
7375

7476

75-
def test_path_run_single_glyph_non_composite_no_contours_nocolor(capsys, monkeypatch):
77+
def test_direction_run_single_glyph_non_composite_no_contours_nocolor(
78+
capsys, monkeypatch
79+
):
7680
def mock_isatty():
7781
return True
7882

@@ -88,7 +92,9 @@ def mock_isatty():
8892
assert "[ .notdef ]: no contours" in captured.out
8993

9094

91-
def test_path_run_single_glyph_non_composite_clockwise_default(capsys, monkeypatch):
95+
def test_direction_run_single_glyph_non_composite_clockwise_default(
96+
capsys, monkeypatch
97+
):
9298
def mock_isatty():
9399
return True
94100

@@ -104,7 +110,9 @@ def mock_isatty():
104110
assert "[ \x1b[1;36mA\x1b[0m ]: clockwise" in captured.out
105111

106112

107-
def test_path_run_single_glyph_non_composite_clockwise_nocolor(capsys, monkeypatch):
113+
def test_dierection_run_single_glyph_non_composite_clockwise_nocolor(
114+
capsys, monkeypatch
115+
):
108116
def mock_isatty():
109117
return True
110118

@@ -120,7 +128,9 @@ def mock_isatty():
120128
assert "[ A ]: clockwise" in captured.out
121129

122130

123-
def test_path_run_single_glyph_composite_counter_clockwise_default(capsys, monkeypatch):
131+
def test_direction_run_single_glyph_composite_counter_clockwise_default(
132+
capsys, monkeypatch
133+
):
124134
def mock_isatty():
125135
return True
126136

@@ -137,7 +147,9 @@ def mock_isatty():
137147
assert "with component 'question' transform: [[-1.0, 0], [0, 1.0]]" in captured.out
138148

139149

140-
def test_path_run_single_glyph_composite_counter_clockwise_nocolor(capsys, monkeypatch):
150+
def test_direction_run_single_glyph_composite_counter_clockwise_nocolor(
151+
capsys, monkeypatch
152+
):
141153
def mock_isatty():
142154
return True
143155

@@ -156,3 +168,49 @@ def mock_isatty():
156168
" with component 'question' transform: [[-1.0, 0], [0, 1.0]]"
157169
in captured.out
158170
)
171+
172+
173+
def test_direction_run_full_glyph_default(capsys, monkeypatch):
174+
def mock_isatty():
175+
return True
176+
177+
# apply the monkeypatch for sys.stdout.isatty()
178+
monkeypatch.setattr(sys.stdout, "isatty", mock_isatty)
179+
180+
args = parser.parse_args([TESTFONT_PATH_1])
181+
direction_run(args)
182+
183+
captured = capsys.readouterr()
184+
assert "[ \x1b[1;36m.notdef\x1b[0m ]: no contours" in captured.out
185+
assert "[ \x1b[1;36mspace\x1b[0m ]: no contours" in captured.out
186+
assert "[ \x1b[1;36mcomma\x1b[0m ]: clockwise" in captured.out
187+
assert "[ \x1b[1;36mquestion\x1b[0m ]: clockwise" in captured.out
188+
assert "[ \x1b[1;36mA\x1b[0m ]: clockwise" in captured.out
189+
assert "[ \x1b[1;36muni2E2E\x1b[0m ]: counter-clockwise" in captured.out
190+
assert (
191+
" with component 'question' transform: [[-1.0, 0], [0, 1.0]]"
192+
in captured.out
193+
)
194+
195+
196+
def test_direction_run_full_glyph_nocolor(capsys, monkeypatch):
197+
def mock_isatty():
198+
return True
199+
200+
# apply the monkeypatch for sys.stdout.isatty()
201+
monkeypatch.setattr(sys.stdout, "isatty", mock_isatty)
202+
203+
args = parser.parse_args(["--nocolor", TESTFONT_PATH_1])
204+
direction_run(args)
205+
206+
captured = capsys.readouterr()
207+
assert "[ .notdef ]: no contours" in captured.out
208+
assert "[ space ]: no contours" in captured.out
209+
assert "[ comma ]: clockwise" in captured.out
210+
assert "[ question ]: clockwise" in captured.out
211+
assert "[ A ]: clockwise" in captured.out
212+
assert "[ uni2E2E ]: counter-clockwise" in captured.out
213+
assert (
214+
" with component 'question' transform: [[-1.0, 0], [0, 1.0]]"
215+
in captured.out
216+
)

0 commit comments

Comments
 (0)