Should assume() filter explicit examples?

18 views
Skip to first unread message

Paul Wolneykien

unread,
Sep 5, 2022, 6:31:23 AM9/5/22
to Hypothesis users
Hi. Should `assume()` silently filter explicit examples? I think it's an error. If an @example is filtered out by assume(), then its case just isn't checked. However, the code looks like all explicit examples are passing.

Zac Hatfield Dodds

unread,
Sep 5, 2022, 4:50:29 PM9/5/22
to Paul Wolneykien, Hypothesis users
Hi Paul

While it's a little odd, we implemented this deliberately to better support use-cases with a mixture of `@example()`, `@given()`, and `@pytest.mark.parametrize()` (or a parametrized fixture, or other similar framework).  You can trace some discussions back from https://hypothesis.readthedocs.io/en/latest/changes.html#v5-11-0 if you're interested!

I did spend a while this morning playing around with ways to warn if *all* examples were skipped by `assume()`, but couldn't find one that didn't give false alarms when e.g. only a subset of parametrizations were selected to be executed (using for example `pytest -k ...`).

Hope that helps,
Zac




On Mon, 5 Sept 2022 at 03:31, Paul Wolneykien <wolne...@gmail.com> wrote:
Hi. Should `assume()` silently filter explicit examples? I think it's an error. If an @example is filtered out by assume(), then its case just isn't checked. However, the code looks like all explicit examples are passing.

--
You received this message because you are subscribed to the Google Groups "Hypothesis users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hypothesis-use...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/hypothesis-users/8b9a5584-0b39-44c6-9a51-77ac7504428en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages