Skip to content

Commit 6a9950e

Browse files
Update plugin.py
1 parent a596c39 commit 6a9950e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/pytest_codspeed/plugin.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,12 @@ def _measure_context(node: pytest.Item) -> AsyncIterator[None]
244244
gc.collect()
245245
gc.disable()
246246

247-
yield
248-
249-
# Ensure GC is re-enabled even if the test failed
250-
if is_gc_enabled:
251-
gc.enable()
247+
try:
248+
yield
249+
finally:
250+
# Ensure GC is re-enabled even if the test failed
251+
if is_gc_enabled:
252+
gc.enable()
252253

253254

254255
async def _async_measure(

0 commit comments

Comments
 (0)