Skip to content

Commit 7f2d4d4

Browse files
committed
add benchmark fixture for codeflash benchmarking
1 parent 5482f6d commit 7f2d4d4

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tests/test_examples.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ def tmp_path_cwd(tmp_path: Path):
106106
os.chdir(cwd)
107107
sys.path.remove(str(tmp_path))
108108

109-
110109
@pytest.mark.xdist_group(name='doc_tests')
111110
@pytest.mark.parametrize('example', find_filter_examples())
112111
def test_docs_examples( # noqa: C901
@@ -117,6 +116,7 @@ def test_docs_examples( # noqa: C901
117116
allow_model_requests: None,
118117
env: TestEnv,
119118
tmp_path_cwd: Path,
119+
benchmark: Any
120120
):
121121
mocker.patch('pydantic_ai.agent.models.infer_model', side_effect=mock_infer_model)
122122
mocker.patch('pydantic_ai._utils.group_by_temporal', side_effect=mock_group_by_temporal)
@@ -216,9 +216,19 @@ def print(self, *args: Any, **kwargs: Any) -> None:
216216
test_globals: dict[str, str] = {'__name__': dunder_name}
217217

218218
if eval_example.update_examples: # pragma: lax no cover
219-
eval_example.run_print_update(example, call=call_name, module_globals=test_globals)
219+
benchmark(
220+
eval_example.run_print_update,
221+
example,
222+
call=call_name,
223+
module_globals=test_globals,
224+
)
220225
else:
221-
eval_example.run_print_check(example, call=call_name, module_globals=test_globals)
226+
benchmark(
227+
eval_example.run_print_check,
228+
example,
229+
call=call_name,
230+
module_globals=test_globals,
231+
)
222232

223233

224234
def print_callback(s: str) -> str:

0 commit comments

Comments
 (0)