In array-api-tests, we have a custom pytest mark, `unvectorized`, which makes a decorated test use 1/10th of `--max-examples` [1].
We're not using `@ settings(max_examples=...)` directly because we don't set the number itself, we want to decrease the user-provided number by a factor of ten.
Our implementation works for standalone test functions, but breaks down for test methods grouped into a test class
class TestSomething:
@pytest.mark.unvectorized
@given(....)
def test(self, ....):
.....
The failure is due to us having to apply `hypothesis.settings` to a pytest "item", so it's clearly on us, and this email is me asking for advice.
AFAICS, the key problem I'm having is that I've to apply `settings` to a function---and modifying a test function is a bit awkward in pytest.
Now, a Copilot-drafted fix [2] uses `inspect` and pytest's `item.cls` to reattach the result of applying `setting(max_examples=...)(test_function)`. Previous copilot iterations included such beauties as `setattr(item.obj.__self.__class__, item.obj.__name__, settings(max_examples=...)(test_func)`.
This all looks quite backwards to me, so I wonder if there's a better / recommended way to modify a parameter of hypothesis settings for a test, and wold appreciate any pointers.
Either way, thanks for the hypothesis!
Evgeni