Skip to content

Commit c1d3030

Browse files
refactor(benchmarks): harden corpus helpers in conftest
Parse the JSONL template once per write_jsonl call and deepcopy entries in the loop. Use exist_ok=True when creating bench-project in seed_search_corpus.
1 parent 68ba23c commit c1d3030

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tests/benchmarks/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import json
6+
from copy import deepcopy
67
from pathlib import Path
78

89
import pytest
@@ -15,9 +16,10 @@
1516

1617
def write_jsonl(path: Path, line_count: int) -> Path:
1718
"""Write a JSONL session file with *line_count* rows derived from the template fixture."""
19+
template = json.loads(TEMPLATE_LINE)
1820
with path.open("w", encoding="utf-8") as f:
1921
for i in range(line_count):
20-
entry = json.loads(TEMPLATE_LINE)
22+
entry = deepcopy(template)
2123
entry["timestamp"] = f"2026-06-12T10:{i % 60:02d}:00Z"
2224
if i % 3 == 1:
2325
msg = entry.setdefault("message", {})
@@ -39,7 +41,7 @@ def seed_search_corpus(
3941
) -> Path:
4042
"""Create a multi-session project tree under *base_dir* for search benchmarks."""
4143
project = base_dir / "bench-project"
42-
project.mkdir(parents=True)
44+
project.mkdir(parents=True, exist_ok=True)
4345
for i in range(session_count):
4446
write_jsonl(project / f"session_{i:04d}.jsonl", lines_per_session)
4547
return base_dir

0 commit comments

Comments
 (0)