ionelmc / pytest-benchmark

py.test fixture for benchmarking code
BSD 2-Clause "Simplified" License
1.24k stars 119 forks source link

pytest-benchmark causes hypothesis tests to fail #241

Closed mtelka closed 1 year ago

mtelka commented 1 year ago

When there is pytest-benchmark installed few tests for hypothesis Python project fails. For more details please see https://github.com/HypothesisWorks/hypothesis/issues/3642

ionelmc commented 1 year ago

The problem is caused by this monkeypatching here: https://github.com/HypothesisWorks/hypothesis/blob/master/hypothesis-python/tests/conftest.py#L76-L91

My plugin expects that the default timer has a valid and importable qualname.

Because I don't have control over when my plugin is actually imported there's little I can do from my side besides having a confusing default for the --benchmark-timer option that won't get messed up by incomplete monkeypatching. I don't really want that.

My suggestion is to add something along these lines in that fixture:

time.__module__ = 'time'
time.__name__ = 'perf_counter'