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

Deprecate use of assume or reject outside of tests #3748 #3751

Merged
merged 11 commits into from Sep 25, 2023

Conversation

nickcollins
Copy link
Contributor

@nickcollins nickcollins commented Sep 22, 2023

If some code outside a test (e.g. execute_example) calls assume or reject, they raise UnsatisfiedAssumption, which is an internal exception that should generally not seen by user code. This branch provides a warning deprecating such use cases, which helps clarify to the user that they are getting the exception because they have called these functions from the wrong places.

A continuation of #3748 because I messed up the branch on that one and had to create a new branch.

Fixes #3743 and fixes #3753.

@nickcollins
Copy link
Contributor Author

Some of the tests are failing, including at least one of the tests I wrote, but I don't know how to read the test output to see what is wrong. Is there a way I can run the tests without adding a commit and invoking the CI?

@Zac-HD
Copy link
Member

Zac-HD commented Sep 24, 2023

You can click the "details" link next to the checks below this comment, which will lead e.g. here. You can run them locally with e.g. make format or make check-py310-cover; more details here.

Comment on lines 3 to 4
Deprecate use of :func:`~hypothesis.control.assume` and
:func:`~hypothesis.control.reject` outside of tests.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Deprecate use of :func:`~hypothesis.control.assume` and
:func:`~hypothesis.control.reject` outside of tests.
Deprecate use of :func:`~hypothesis.assume` and :func:`~hypothesis.reject` from
outside a Hypothesis context, because these functions work by raising a special exception.

important to note that it's not "outside a test", but outside a particular kind of test. I think it's worth explaining why, too, and would do both in the deprecation message.

nickcollins and others added 9 commits September 24, 2023 01:55
If some code outside a test (e.g. `execute_example`) calls `assume` or `reject`, they raise `UnsatisfiedAssumption`, which is an internal exception that should generally not seen by user code. This commit provides a warning deprecating such use cases, which helps clarify to the user that they are getting the exception because they have called these functions from the wrong places.
@Zac-HD
Copy link
Member

Zac-HD commented Sep 24, 2023

...this has turned out to trigger some complicated latent issues in our engine, which are way more complicated than I anticipated. I'll push a commit to fix that, and then merge 🚀

@Zac-HD Zac-HD force-pushed the no-assume-outside-context-4 branch 2 times, most recently from fec0179 to 3a58f45 Compare September 24, 2023 19:28
@nickcollins
Copy link
Contributor Author

Ok, thanks!

@Zac-HD Zac-HD merged commit 61b2940 into HypothesisWorks:master Sep 25, 2023
47 checks passed
@nickcollins nickcollins deleted the no-assume-outside-context-4 branch September 25, 2023 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants