11import os
2- import shutil
32import tempfile
43import pytest
54from typer .testing import CliRunner
65from unittest import mock
76from firefly .cli import app , mock_image
7+ import re
88
99runner = CliRunner ()
1010
@@ -48,7 +48,7 @@ def test_generate_download_image(monkeypatch):
4848 with open (os .path .join (os .path .dirname (__file__ ), "images" , "cat-coding.png" ), "rb" ) as f :
4949 expected = f .read ()
5050 assert content == expected
51- assert f "Downloaded image (" in result .output
51+ assert "Downloaded image (" in result .output
5252
5353@mock .patch ("subprocess.run" )
5454def test_generate_show_images (mock_run ):
@@ -190,6 +190,10 @@ def test_generate_with_all_new_options(monkeypatch):
190190 assert result .exit_code != 0
191191 assert "content_class must be either 'photo' or 'art'" in result .output
192192
193+ def strip_ansi (text ):
194+ ansi_escape = re .compile (r'\x1b\[[0-9;]*[mGKHF]' )
195+ return ansi_escape .sub ('' , text )
196+
193197def test_generate_invalid_json_style (monkeypatch ):
194198 result = runner .invoke (
195199 app ,
@@ -203,7 +207,8 @@ def test_generate_invalid_json_style(monkeypatch):
203207 ]
204208 )
205209 assert result .exit_code == 2
206- assert "Invalid JSON for --style" in result .output
210+ assert "Invalid JSON for --style" in strip_ansi (result .output )
211+
207212
208213def test_generate_invalid_json_structure (monkeypatch ):
209214 result = runner .invoke (
@@ -218,7 +223,7 @@ def test_generate_invalid_json_structure(monkeypatch):
218223 ]
219224 )
220225 assert result .exit_code == 2
221- assert "Invalid JSON for --structure" in result .output
226+ assert "Invalid JSON for --structure" in strip_ansi ( result .output )
222227
223228def test_generate_invalid_num_variations (monkeypatch ):
224229 # Test too low
0 commit comments