File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 44from typer .testing import CliRunner
55from unittest import mock
66from firefly .cli import app , mock_image
7+ import re
78
89runner = CliRunner ()
910
@@ -189,6 +190,10 @@ def test_generate_with_all_new_options(monkeypatch):
189190 assert result .exit_code != 0
190191 assert "content_class must be either 'photo' or 'art'" in result .output
191192
193+ def strip_ansi (text ):
194+ ansi_escape = re .compile (r'\x1b\[[0-9;]*[mGKHF]' )
195+ return ansi_escape .sub ('' , text )
196+
192197def test_generate_invalid_json_style (monkeypatch ):
193198 result = runner .invoke (
194199 app ,
@@ -202,7 +207,8 @@ def test_generate_invalid_json_style(monkeypatch):
202207 ]
203208 )
204209 assert result .exit_code == 2
205- assert "Invalid JSON for --style" in result .output
210+ assert "Invalid JSON for --style" in strip_ansi (result .output )
211+
206212
207213def test_generate_invalid_json_structure (monkeypatch ):
208214 result = runner .invoke (
@@ -217,7 +223,7 @@ def test_generate_invalid_json_structure(monkeypatch):
217223 ]
218224 )
219225 assert result .exit_code == 2
220- assert "Invalid JSON for --structure" in result .output
226+ assert "Invalid JSON for --structure" in strip_ansi ( result .output )
221227
222228def test_generate_invalid_num_variations (monkeypatch ):
223229 # Test too low
You can’t perform that action at this time.
0 commit comments