Skip to content

Commit d6511e3

Browse files
committed
Add a clearer error message when users redefine the benchmark fixture to something incompatible. Closes #265.
1 parent 15557b0 commit d6511e3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/pytest_benchmark/plugin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,11 @@ def pytest_runtest_setup(item):
489489
def pytest_runtest_makereport(item, call):
490490
outcome = yield
491491
fixture = hasattr(item, 'funcargs') and item.funcargs.get('benchmark')
492+
if fixture is not None and not isinstance(fixture, BenchmarkFixture):
493+
raise TypeError(
494+
f'unexpected type for `benchmark` in funcargs, {fixture!r} must be a BenchmarkFixture instance.'
495+
'You should not use other plugins that define a `benchmark` fixture, or return and unexpected value if you do redefine it.'
496+
)
492497
if fixture:
493498
fixture.skipped = outcome.get_result().outcome == 'skipped'
494499

0 commit comments

Comments
 (0)