Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move pytest-trio's hook for deterministic Hypothesis tests upstream into Trio #2981

Closed
Zac-HD opened this issue Mar 30, 2024 · 0 comments · Fixed by #2985
Closed

Move pytest-trio's hook for deterministic Hypothesis tests upstream into Trio #2981

Zac-HD opened this issue Mar 30, 2024 · 0 comments · Fixed by #2985

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Mar 30, 2024

pytest-trio does two things for property-based tests with Hypothesis:

  1. Inserts the async-to-sync wrapper logic. pytest-trio is clearly the right place to do that.
  2. Registers Trio's internal Random instance so that the scheduler is deterministic and Hypothesis can replay failing examples (see Deterministic scheduling via Hypothesis pytest-trio#73 and Support deterministic scheduling #890).

At the time, pytest-trio was the right place to do (2), but not anymore: since HypothesisWorks/hypothesis#2556, it's possible for Trio to ship a Hypothesis plugin which handles the registration if-and-only-if Hypothesis is imported. Here are the docs.

This is useful because it works even for users without pytest-trio installed or enabled (c.f. HypothesisWorks/hypothesis#3940), e.g. because they're using unittest or running a test function by hand in some debugging loop or the test function calls trio.run() internally, and it will allow pytest-trio to avoid importing Hypothesis if it wasn't otherwise going to be used (which is nice for performance).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant