@@ -141,14 +141,16 @@ def pytest_collection_modifyitems(
141141 items [:] = selected
142142
143143
144- def _run_with_instrumentation (lib : "LibType" , fn : Callable [[], Any ], nodeId : str ):
144+ def _run_with_instrumentation (
145+ lib : "LibType" , nodeId : str , fn : Callable [..., Any ], * args , ** kwargs
146+ ):
145147 is_gc_enabled = gc .isenabled ()
146148 if is_gc_enabled :
147149 gc .collect ()
148150 gc .disable ()
149151 lib .zero_stats ()
150152 lib .start_instrumentation ()
151- fn ()
153+ fn (* args , ** kwargs )
152154 lib .stop_instrumentation ()
153155 lib .dump_stats_at (f"{ nodeId } " .encode ("ascii" ))
154156 if is_gc_enabled :
@@ -170,7 +172,7 @@ def pytest_runtest_call(item: "pytest.Item"):
170172 item .runtest ()
171173 else :
172174 assert plugin .lib is not None
173- _run_with_instrumentation (plugin .lib , item .runtest , item .nodeid )
175+ _run_with_instrumentation (plugin .lib , item .nodeid , item .runtest )
174176
175177
176178@pytest .hookimpl ()
@@ -192,9 +194,7 @@ def codspeed_benchmark(request: "pytest.FixtureRequest") -> Callable:
192194 def run (func : Callable [..., Any ], * args : Any ):
193195 if plugin .is_codspeed_enabled and plugin .should_measure :
194196 assert plugin .lib is not None
195- _run_with_instrumentation (
196- plugin .lib , lambda : func (* args ), request .node .nodeid
197- )
197+ _run_with_instrumentation (plugin .lib , request .node .nodeid , func , * args )
198198 else :
199199 func (* args )
200200
0 commit comments