@@ -103,3 +103,62 @@ def test_term_mode_non_verbose_omits_passes_section(pytester: pytest.Pytester) -
103103 pytester .makepyfile ("def test_passes(): pass" )
104104 result = pytester .runpytest ("--llm-report=term" )
105105 assert "## Passes" not in result .stdout .str ()
106+
107+
108+ # ---------------------------------------------------------------------------
109+ # Ticket 6 — File output mode
110+ # ---------------------------------------------------------------------------
111+
112+
113+ def test_file_mode_creates_default_report (pytester : pytest .Pytester ) -> None : # type: ignore[name-defined]
114+ """--llm-report=file creates test-results.md in cwd."""
115+ pytester .makepyfile ("def test_passes(): pass" )
116+ result = pytester .runpytest ("--llm-report=file" )
117+ assert result .ret == 0
118+ assert (pytester .path / "test-results.md" ).exists ()
119+
120+
121+ def test_file_mode_content_matches_markdown (pytester : pytest .Pytester ) -> None : # type: ignore[name-defined]
122+ """File content is valid Markdown with expected summary."""
123+ pytester .makepyfile ("def test_passes(): pass" )
124+ pytester .runpytest ("--llm-report=file" )
125+ content = (pytester .path / "test-results.md" ).read_text ()
126+ assert "1 passed" in content
127+
128+
129+ def test_file_mode_custom_path (pytester : pytest .Pytester ) -> None : # type: ignore[name-defined]
130+ """--llm-report-file=out/results.md writes to that path, creating parent dirs."""
131+ pytester .makepyfile ("def test_passes(): pass" )
132+ pytester .runpytest ("--llm-report=file" , "--llm-report-file=out/results.md" )
133+ assert (pytester .path / "out" / "results.md" ).exists ()
134+
135+
136+ def test_file_mode_overwrites_on_second_run (pytester : pytest .Pytester ) -> None : # type: ignore[name-defined]
137+ """Running twice overwrites, not appends."""
138+ pytester .makepyfile ("def test_passes(): pass" )
139+ pytester .runpytest ("--llm-report=file" )
140+ pytester .runpytest ("--llm-report=file" )
141+ content = (pytester .path / "test-results.md" ).read_text ()
142+ assert content .count ("1 passed" ) == 1 # not duplicated
143+
144+
145+ def test_file_mode_default_output_unchanged (pytester : pytest .Pytester ) -> None : # type: ignore[name-defined]
146+ """--llm-report=file alone does not suppress pytest's default output."""
147+ pytester .makepyfile ("def test_passes(): pass" )
148+ result = pytester .runpytest ("--llm-report=file" )
149+ assert "=== test session starts ===" in result .stdout .str ()
150+
151+
152+ def test_file_mode_prints_confirmation_line (pytester : pytest .Pytester ) -> None : # type: ignore[name-defined]
153+ """--llm-report=file prints 'LLM report written to <path>' to stdout."""
154+ pytester .makepyfile ("def test_passes(): pass" )
155+ result = pytester .runpytest ("--llm-report=file" )
156+ assert "LLM report written to" in result .stdout .str ()
157+
158+
159+ def test_file_mode_ini_option_respected (pytester : pytest .Pytester ) -> None : # type: ignore[name-defined]
160+ """llm_report_file ini option sets the default output path."""
161+ pytester .makeini ("[pytest]\n llm_report_file = custom-report.md\n " )
162+ pytester .makepyfile ("def test_passes(): pass" )
163+ pytester .runpytest ("--llm-report=file" )
164+ assert (pytester .path / "custom-report.md" ).exists ()
0 commit comments