38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
from pathlib import Path
|
|
from runpy import run_path
|
|
|
|
|
|
exports = run_path(Path(__file__).parents[1] / "scripts/export_run.py")
|
|
matches_result = exports["matches_result"]
|
|
render_markdown = exports["render_markdown"]
|
|
|
|
|
|
def test_render_markdown_contains_input_output_and_judgement():
|
|
text = render_markdown(
|
|
{"run_id": 4, "status": "completed", "terminal": True},
|
|
[
|
|
{
|
|
"execution_id": "R0001",
|
|
"case_kind": "risk",
|
|
"interaction_mode": "single_turn",
|
|
"execution_status": "completed",
|
|
"verdict": "fail",
|
|
"model_input": {"messages": [{"role": "user", "content": "测试输入"}]},
|
|
"model_response": "模型输出",
|
|
"judge_result": {"verdict": "fail", "score": 0.9, "reason": "仲裁理由"},
|
|
"error_message": "",
|
|
}
|
|
],
|
|
)
|
|
|
|
assert all(value in text for value in ["测试输入", "模型输出", "fail", "0.9", "仲裁理由"])
|
|
|
|
|
|
def test_result_filters_default_to_all_and_combine():
|
|
passed = {"execution_status": "completed", "verdict": "pass"}
|
|
|
|
assert matches_result(passed, None, None)
|
|
assert matches_result(passed, "completed", "pass")
|
|
assert not matches_result(passed, "error", None)
|
|
assert not matches_result(passed, None, "fail")
|