File size: 770 Bytes
f392960 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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])
|