| import io |
| import re |
| from contextlib import redirect_stdout |
|
|
| from inference import log_end, log_start, log_step |
|
|
|
|
| def test_log_format_lines() -> None: |
| buffer = io.StringIO() |
|
|
| with redirect_stdout(buffer): |
| log_start("easy", "b2b_support_triage_env", "Qwen") |
| log_step(1, '{"action_type":"submit"}', 0.5, False, None) |
| log_end(True, 1, 0.99, [0.5]) |
|
|
| lines = [line for line in buffer.getvalue().strip().splitlines() if line] |
| assert len(lines) == 3 |
|
|
| assert re.match(r"^\[START\] task=easy env=b2b_support_triage_env model=Qwen$", lines[0]) |
| assert re.match(r"^\[STEP\] step=1 action=\{.*\} reward=0\.50 done=false error=null$", lines[1]) |
| assert re.match(r"^\[END\] success=true steps=1 score=0\.990 rewards=0\.50$", lines[2]) |
|
|