-
Notifications
You must be signed in to change notification settings - Fork 159
Support for hypothesis in async methods #93
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
Comments
what is the status of this, I would like to use hypothesis for my async project so my tests must also be async ... and don't want to use trio. I was thinking of doing something like this
|
turned it into a fixture
|
Just a quick remark: the try/finally block is not required for pytest fixtures, the code after the |
neat, makes sense .. i copy pasted the code into a fixture, thats why i kept it like that |
Hi all, maintainer of Hypothesis + Trio + Pytest here - I wrote the linked integration and would be happy to have a go here. Only reason I hadn't already added this was that I don't use FYI @japrogramer the integration is basically equivalent to your fixture / @carver's decorator, automatically applied to all tests with |
OK, a first attempt is up as #102. @carver @japrogramer - can you check that this works for you? |
Yes, the change does appear to work on the hypothesis tests, when I However... my other
(they are all green with pytest-asyncio v0.9.0) I haven't had a chance to dig into why, but maybe it is unrelated to your change. |
@carver that error means that a coroutine was never awaited but called as if it where. I merged the pull request into master and this is what i got
|
Right, but the method that isn't being |
It looks like my detection to avoid wrapping Hypothesis tests twice was a bit too loose - try again with 1b66314? |
Yup, all green! |
@Zac-HD not for me .. hmm, am i running this correctly?
and here is the diff from master
pip freeze
|
Hmm, that's the correct diff from master at least. One skip and one xfail might not actually be a problem though - can you check if they occur on master? |
thats weird i uninstalled and git reset --hard to be on master again
|
OK, I've just gone and checked - neither of those are problems and both are present on master, so it looks like my patch does work 🎉 |
I tried the patch and it seems to work. I have to deal with "future attached to a different loop" problems, but interaction with hypothesis seems to work at least. |
Although, I suspect that the "attached to a different loop" problems I'm having may be due to this patch, since it does Yes, things will fail because By changing |
hypothesis
exits early when used on pytest-asyncio tests, complaining that the test returns a coroutine instead of None. This issue talks about how trio added support for hypothesis: HypothesisWorks/hypothesis#968I can work around this with a decorator:
But it looks like the recommended approach is to tinker with the hypothesis attribute added to the test, like: https://github.com/python-trio/pytest-trio/pull/44/files#diff-aacce3c1178656a02aecc59c94209433R231
Is this something pytest-asyncio is interested in supporting?
The text was updated successfully, but these errors were encountered: