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

Document reject() function. #3535

Closed
jenstroeger opened this issue Dec 28, 2022 · 4 comments
Closed

Document reject() function. #3535

jenstroeger opened this issue Dec 28, 2022 · 4 comments
Assignees
Labels
docs documentation could *always* be better

Comments

@jenstroeger
Copy link
Contributor

I noticed that e.g. the Getting started with Hypothesis article demonstrates the use of hypothesis.reject(). However, I wasn’t able to find more documentation on that function, likely because there is none:

def reject() -> NoReturn:
raise UnsatisfiedAssumption()

Would it make sense/be possible to elaborate?

Thank you!

@rsokl rsokl added the docs documentation could *always* be better label Dec 29, 2022
@rsokl
Copy link
Contributor

rsokl commented Dec 29, 2022

I think a reasonable description would be:

"""
Discards an example by raising `UnsatisfiableAssumption`.

Hypothesis won’t count it towards the ‘budget’ of examples it is allowed to run.
"""

I'll add documentation to this function. Thanks for bringing this to our attention! 🙏

@rsokl rsokl self-assigned this Dec 29, 2022
@jenstroeger
Copy link
Contributor Author

Great, thank you @rsokl!

@Zac-HD
Copy link
Member

Zac-HD commented Jan 7, 2023

The reason you won't see it anywhere in the docs is that I'd prefer to point people to assume(False) - since this is exactly equivalent and I'd rather have only one (obvious) way to do it.

See #2943 for steps to get this fixed in the article though 😓

@Zac-HD Zac-HD closed this as completed Jan 7, 2023
@jenstroeger
Copy link
Contributor Author

That makes sense, thanks @Zac-HD

Perhaps for the sake of making your intent clear it might make sense then to implement reject() by calling assume():

def reject() -> bool:
    return assume(False)

That would also raise the UnsatisfiedAssumption at the cost of an extra function call… 🤔 Anyway. All good 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs documentation could *always* be better
Projects
None yet
Development

No branches or pull requests

3 participants