Skip to content

Commit fc3cbc2

Browse files
committed
add benchmark fixture for codeflash benchmarking
1 parent cbb2c18 commit fc3cbc2

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
@@ -103,7 +103,6 @@ def tmp_path_cwd(tmp_path: Path):
103103
os.chdir(cwd)
104104
sys.path.remove(str(tmp_path))
105105

106-
107106
@pytest.mark.xdist_group(name='doc_tests')
108107
@pytest.mark.parametrize('example', find_filter_examples())
109108
def test_docs_examples( # noqa: C901
@@ -114,6 +113,7 @@ def test_docs_examples( # noqa: C901
114113
allow_model_requests: None,
115114
env: TestEnv,
116115
tmp_path_cwd: Path,
116+
benchmark: Any
117117
):
118118
mocker.patch('pydantic_ai.agent.models.infer_model', side_effect=mock_infer_model)
119119
mocker.patch('pydantic_ai._utils.group_by_temporal', side_effect=mock_group_by_temporal)
@@ -212,9 +212,19 @@ def print(self, *args: Any, **kwargs: Any) -> None:
212212
test_globals: dict[str, str] = {'__name__': dunder_name}
213213

214214
if eval_example.update_examples: # pragma: lax no cover
215-
eval_example.run_print_update(example, call=call_name, module_globals=test_globals)
215+
benchmark(
216+
eval_example.run_print_update,
217+
example,
218+
call=call_name,
219+
module_globals=test_globals,
220+
)
216221
else:
217-
eval_example.run_print_check(example, call=call_name, module_globals=test_globals)
222+
benchmark(
223+
eval_example.run_print_check,
224+
example,
225+
call=call_name,
226+
module_globals=test_globals,
227+
)
218228

219229

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

0 commit comments

Comments
 (0)