1+ # cspell:ignore capsys
12"""Tests for the ansi module."""
23
34from __future__ import annotations
2223
2324
2425def test_changed_with_color (capsys : pytest .CaptureFixture [str ]) -> None :
25- """Test changed output with color enabled."""
26+ """Test changed output with color enabled.
27+
28+ Args:
29+ capsys: The capsys fixture
30+ """
2631 changed (color = True , message = "something changed" )
2732 captured = capsys .readouterr ()
2833 assert Color .YELLOW in captured .out
@@ -31,111 +36,175 @@ def test_changed_with_color(capsys: pytest.CaptureFixture[str]) -> None:
3136
3237
3338def test_changed_without_color (capsys : pytest .CaptureFixture [str ]) -> None :
34- """Test changed output without color."""
39+ """Test changed output without color.
40+
41+ Args:
42+ capsys: The capsys fixture
43+ """
3544 changed (color = False , message = "something changed" )
3645 captured = capsys .readouterr ()
3746 assert captured .out .strip () == "something changed"
3847 assert Color .YELLOW not in captured .out
3948
4049
4150def test_failed_with_color (capsys : pytest .CaptureFixture [str ]) -> None :
42- """Test failed output with color enabled."""
51+ """Test failed output with color enabled.
52+
53+ Args:
54+ capsys: The capsys fixture
55+ """
4356 failed (color = True , message = "it failed" )
4457 captured = capsys .readouterr ()
4558 assert Color .RED in captured .out
4659 assert "it failed" in captured .out
4760
4861
4962def test_failed_without_color (capsys : pytest .CaptureFixture [str ]) -> None :
50- """Test failed output without color."""
63+ """Test failed output without color.
64+
65+ Args:
66+ capsys: The capsys fixture
67+ """
5168 failed (color = False , message = "it failed" )
5269 assert capsys .readouterr ().out .strip () == "it failed"
5370
5471
5572def test_info_with_color (capsys : pytest .CaptureFixture [str ]) -> None :
56- """Test info output with color enabled."""
73+ """Test info output with color enabled.
74+
75+ Args:
76+ capsys: The capsys fixture
77+ """
5778 info (color = True , message = "some info" )
5879 captured = capsys .readouterr ()
5980 assert Color .CYAN in captured .out
6081 assert "some info" in captured .out
6182
6283
6384def test_info_without_color (capsys : pytest .CaptureFixture [str ]) -> None :
64- """Test info output without color."""
85+ """Test info output without color.
86+
87+ Args:
88+ capsys: The capsys fixture
89+ """
6590 info (color = False , message = "some info" )
6691 assert capsys .readouterr ().out .strip () == "some info"
6792
6893
6994def test_subtle_with_color (capsys : pytest .CaptureFixture [str ]) -> None :
70- """Test subtle output with color enabled."""
95+ """Test subtle output with color enabled.
96+
97+ Args:
98+ capsys: The capsys fixture
99+ """
71100 subtle (color = True , message = "subtle msg" )
72101 captured = capsys .readouterr ()
73102 assert Color .GREY in captured .out
74103 assert "subtle msg" in captured .out
75104
76105
77106def test_subtle_without_color (capsys : pytest .CaptureFixture [str ]) -> None :
78- """Test subtle output without color."""
107+ """Test subtle output without color.
108+
109+ Args:
110+ capsys: The capsys fixture
111+ """
79112 subtle (color = False , message = "subtle msg" )
80113 assert capsys .readouterr ().out .strip () == "subtle msg"
81114
82115
83116def test_success_with_color (capsys : pytest .CaptureFixture [str ]) -> None :
84- """Test success output with color enabled."""
117+ """Test success output with color enabled.
118+
119+ Args:
120+ capsys: The capsys fixture
121+ """
85122 success (color = True , message = "it worked" )
86123 captured = capsys .readouterr ()
87124 assert Color .GREEN in captured .out
88125 assert "it worked" in captured .out
89126
90127
91128def test_success_without_color (capsys : pytest .CaptureFixture [str ]) -> None :
92- """Test success output without color."""
129+ """Test success output without color.
130+
131+ Args:
132+ capsys: The capsys fixture
133+ """
93134 success (color = False , message = "it worked" )
94135 assert capsys .readouterr ().out .strip () == "it worked"
95136
96137
97138def test_warning_with_color (capsys : pytest .CaptureFixture [str ]) -> None :
98- """Test warning output with color enabled."""
139+ """Test warning output with color enabled.
140+
141+ Args:
142+ capsys: The capsys fixture
143+ """
99144 warning (color = True , message = "be careful" )
100145 captured = capsys .readouterr ()
101146 assert Color .YELLOW in captured .out
102147 assert "be careful" in captured .out
103148
104149
105150def test_warning_without_color (capsys : pytest .CaptureFixture [str ]) -> None :
106- """Test warning output without color."""
151+ """Test warning output without color.
152+
153+ Args:
154+ capsys: The capsys fixture
155+ """
107156 warning (color = False , message = "be careful" )
108157 assert capsys .readouterr ().out .strip () == "be careful"
109158
110159
111160def test_working_with_color (capsys : pytest .CaptureFixture [str ]) -> None :
112- """Test working output with color enabled."""
161+ """Test working output with color enabled.
162+
163+ Args:
164+ capsys: The capsys fixture
165+ """
113166 working (color = True , message = "processing" )
114167 captured = capsys .readouterr ()
115168 assert Color .GREY in captured .out
116169 assert "processing" in captured .out
117170
118171
119172def test_working_without_color (capsys : pytest .CaptureFixture [str ]) -> None :
120- """Test working output without color."""
173+ """Test working output without color.
174+
175+ Args:
176+ capsys: The capsys fixture
177+ """
121178 working (color = False , message = "processing" )
122179 assert capsys .readouterr ().out .strip () == "processing"
123180
124181
125182def test_blank_line (capsys : pytest .CaptureFixture [str ]) -> None :
126- """Test blank line output."""
183+ """Test blank line output.
184+
185+ Args:
186+ capsys: The capsys fixture
187+ """
127188 blank_line ()
128189 assert capsys .readouterr ().out == "\n "
129190
130191
131192def test_prompt_enter (monkeypatch : pytest .MonkeyPatch ) -> None :
132- """Test prompt_enter with normal input."""
193+ """Test prompt_enter with normal input.
194+
195+ Args:
196+ monkeypatch: The monkeypatch fixture
197+ """
133198 monkeypatch .setattr ("builtins.input" , lambda _ : "" )
134199 prompt_enter ()
135200
136201
137202def test_prompt_enter_keyboard_interrupt (monkeypatch : pytest .MonkeyPatch ) -> None :
138- """Test prompt_enter exits on KeyboardInterrupt."""
203+ """Test prompt_enter exits on KeyboardInterrupt.
204+
205+ Args:
206+ monkeypatch: The monkeypatch fixture
207+ """
139208 def raise_keyboard_interrupt (_ : str ) -> None :
140209 raise KeyboardInterrupt
141210
@@ -146,25 +215,41 @@ def raise_keyboard_interrupt(_: str) -> None:
146215
147216
148217def test_prompt_yn_yes (monkeypatch : pytest .MonkeyPatch ) -> None :
149- """Test prompt_yn returns True for 'y'."""
218+ """Test prompt_yn returns True for 'y'.
219+
220+ Args:
221+ monkeypatch: The monkeypatch fixture
222+ """
150223 monkeypatch .setattr ("builtins.input" , lambda _ : "y" )
151224 assert prompt_yn ("Continue?" ) is True
152225
153226
154227def test_prompt_yn_empty (monkeypatch : pytest .MonkeyPatch ) -> None :
155- """Test prompt_yn returns True for empty input (default yes)."""
228+ """Test prompt_yn returns True for empty input (default yes).
229+
230+ Args:
231+ monkeypatch: The monkeypatch fixture
232+ """
156233 monkeypatch .setattr ("builtins.input" , lambda _ : "" )
157234 assert prompt_yn ("Continue?" ) is True
158235
159236
160237def test_prompt_yn_no (monkeypatch : pytest .MonkeyPatch ) -> None :
161- """Test prompt_yn returns False for 'n'."""
238+ """Test prompt_yn returns False for 'n'.
239+
240+ Args:
241+ monkeypatch: The monkeypatch fixture
242+ """
162243 monkeypatch .setattr ("builtins.input" , lambda _ : "n" )
163244 assert prompt_yn ("Continue?" ) is False
164245
165246
166247def test_prompt_yn_keyboard_interrupt (monkeypatch : pytest .MonkeyPatch ) -> None :
167- """Test prompt_yn exits on KeyboardInterrupt."""
248+ """Test prompt_yn exits on KeyboardInterrupt.
249+
250+ Args:
251+ monkeypatch: The monkeypatch fixture
252+ """
168253 def raise_keyboard_interrupt (_ : str ) -> None :
169254 raise KeyboardInterrupt
170255
0 commit comments