|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import json |
| 4 | +import re |
4 | 5 | from dataclasses import dataclass |
5 | 6 | from pathlib import Path |
6 | 7 |
|
@@ -653,11 +654,15 @@ def fail_if_called(settings): |
653 | 654 | assert saved_report["status"] == "status" |
654 | 655 |
|
655 | 656 |
|
| 657 | +_ANSI_ESCAPE_RE = re.compile(r"\x1b\[[0-9;]*m") |
| 658 | + |
| 659 | + |
656 | 660 | def test_reindex_vectors_status_rejects_mutating_flags() -> None: |
657 | 661 | result = runner.invoke(app, ["reindex-vectors", "--status", "--batch-size", "2"]) |
658 | 662 |
|
659 | 663 | assert result.exit_code == 2 |
660 | | - assert "--status cannot be combined" in result.output |
| 664 | + stripped_output = _ANSI_ESCAPE_RE.sub("", result.output) |
| 665 | + assert "--status cannot be combined" in stripped_output |
661 | 666 |
|
662 | 667 |
|
663 | 668 | def test_reindex_vectors_status_does_not_create_state_on_fresh_home( |
@@ -1010,9 +1015,7 @@ def test_diff_command_compares_saved_trace_to_current_results(tmp_path: Path, mo |
1010 | 1015 | reranker.scores_by_text[ |
1011 | 1016 | "# Socket Timeout Guide\n\nSocket timeout troubleshooting and startup checks." |
1012 | 1017 | ] = 0.7 |
1013 | | - reranker.scores_by_text[ |
1014 | | - "Socket Notes\n\nThe socket timeout happens during startup." |
1015 | | - ] = 0.99 |
| 1018 | + reranker.scores_by_text["Socket Notes\n\nThe socket timeout happens during startup."] = 0.99 |
1016 | 1019 |
|
1017 | 1020 | diff_result = runner.invoke( |
1018 | 1021 | app, |
@@ -1114,9 +1117,7 @@ def test_ask_command_can_persist_trace_artifact(tmp_path: Path, monkeypatch) -> |
1114 | 1117 | assert trace_payload["retrieval_snapshot"]["diversity"]["document_capped_count"] >= 0 |
1115 | 1118 | assert trace_payload["retrieval_snapshot"]["diversity"]["unique_document_count"] >= 1 |
1116 | 1119 | assert trace_payload["retrieval_results"] |
1117 | | - assert ( |
1118 | | - trace_payload["generated_answer"]["retrieval_summary"]["cited_chunk_count"] == 2 |
1119 | | - ) |
| 1120 | + assert trace_payload["generated_answer"]["retrieval_summary"]["cited_chunk_count"] == 2 |
1120 | 1121 | assert trace_payload["answer_context_diversity"]["used_chunk_count"] == 2 |
1121 | 1122 | assert trace_payload["answer_context_diversity"]["unique_document_count"] == 2 |
1122 | 1123 | assert trace_payload["generated_answer"]["citations"][0]["chunk_id"] > 0 |
@@ -1262,9 +1263,7 @@ def test_answer_diff_command_compares_ask_traces(tmp_path: Path, monkeypatch) -> |
1262 | 1263 | reranker.scores_by_text[ |
1263 | 1264 | "# Socket Timeout Guide\n\nSocket timeout troubleshooting and startup checks." |
1264 | 1265 | ] = 0.7 |
1265 | | - reranker.scores_by_text[ |
1266 | | - "Socket Notes\n\nThe socket timeout happens during startup." |
1267 | | - ] = 0.99 |
| 1266 | + reranker.scores_by_text["Socket Notes\n\nThe socket timeout happens during startup."] = 0.99 |
1268 | 1267 | monkeypatch.setattr("gpt_rag.cli.build_generation_client", lambda settings: after_generator) |
1269 | 1268 |
|
1270 | 1269 | after_result = runner.invoke( |
@@ -2397,18 +2396,21 @@ def test_trace_verify_reports_invalid_artifacts(tmp_path: Path, monkeypatch) -> |
2397 | 2396 | issues_by_path = { |
2398 | 2397 | Path(report["path"]).name: report["issues"] for report in payload["reports"] |
2399 | 2398 | } |
2400 | | - assert "could not read a JSON object" in issues_by_path[ |
2401 | | - "20260101T000000Z-inspect-broken.json" |
2402 | | - ] |
2403 | | - assert "ask trace must contain generated_answer" in issues_by_path[ |
2404 | | - "20260101T000100Z-ask-wrong.json" |
2405 | | - ] |
2406 | | - assert "ask trace must contain retrieval_snapshot" in issues_by_path[ |
2407 | | - "20260101T000100Z-ask-wrong.json" |
2408 | | - ] |
2409 | | - assert "ask trace must contain retrieval_results" in issues_by_path[ |
2410 | | - "20260101T000100Z-ask-wrong.json" |
2411 | | - ] |
| 2399 | + assert ( |
| 2400 | + "could not read a JSON object" in issues_by_path["20260101T000000Z-inspect-broken.json"] |
| 2401 | + ) |
| 2402 | + assert ( |
| 2403 | + "ask trace must contain generated_answer" |
| 2404 | + in issues_by_path["20260101T000100Z-ask-wrong.json"] |
| 2405 | + ) |
| 2406 | + assert ( |
| 2407 | + "ask trace must contain retrieval_snapshot" |
| 2408 | + in issues_by_path["20260101T000100Z-ask-wrong.json"] |
| 2409 | + ) |
| 2410 | + assert ( |
| 2411 | + "ask trace must contain retrieval_results" |
| 2412 | + in issues_by_path["20260101T000100Z-ask-wrong.json"] |
| 2413 | + ) |
2412 | 2414 | finally: |
2413 | 2415 | load_settings.cache_clear() |
2414 | 2416 |
|
|
0 commit comments