Skip to content

Commit

Permalink
Add a clearer error message when users redefine the benchmark fixture…
Browse files Browse the repository at this point in the history
… to something incompatible. Closes #265.
  • Loading branch information
ionelmc committed Oct 27, 2024
1 parent 15557b0 commit d6511e3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/pytest_benchmark/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,11 @@ def pytest_runtest_setup(item):
def pytest_runtest_makereport(item, call):
outcome = yield
fixture = hasattr(item, 'funcargs') and item.funcargs.get('benchmark')
if fixture is not None and not isinstance(fixture, BenchmarkFixture):
raise TypeError(
f'unexpected type for `benchmark` in funcargs, {fixture!r} must be a BenchmarkFixture instance.'
'You should not use other plugins that define a `benchmark` fixture, or return and unexpected value if you do redefine it.'
)
if fixture:
fixture.skipped = outcome.get_result().outcome == 'skipped'

Expand Down

0 comments on commit d6511e3

Please # to comment.