Fix auto marking of async hypothesis tests in auto mode#259
Fix auto marking of async hypothesis tests in auto mode#259seifertm merged 2 commits intopytest-dev:masterfrom
Conversation
… Hypothesis test. Signed-off-by: Michael Seifert <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #259 +/- ##
==========================================
+ Coverage 92.79% 92.98% +0.18%
==========================================
Files 3 3
Lines 222 228 +6
Branches 32 32
==========================================
+ Hits 206 212 +6
Misses 10 10
Partials 6 6
Continue to review full report at Codecov.
|
asvetlov
left a comment
There was a problem hiding this comment.
I can live with it, sure.
The only note: when we change asyncio_mode to strict in setup.cfg these tests will fail.
That's why I personally prefer pytester.
…thout explicit "asyncio" marker when "--asyncio-mode=auto" is set. The option --asyncio-mode=auto marks all async functions with the asyncio mark during the collection phase. However, when pytest collects the Hypothesis test, the @given decorator has already been applied and the Hypothesis test function is no longer a coroutine. This commit extends the "pytest_pycollect_makeitem" hook to mark Hypothesis tests whose function body is a coroutine. Closes pytest-dev#258 Signed-off-by: Michael Seifert <[email protected]>
bd8f210 to
732c50b
Compare
|
You're right. It's probably a better idea if the tests are decoupled from the project config. I was hoping to avoid the boilerplate that comes with I rewrote the two test cases to use |
The option
--asyncio-mode=automarks all async functions with theasynciomark during the collection phase. However, when pytest collects the Hypothesis test, the@givendecorator has already been applied and the Hypothesis test function is no longer a coroutine.This commit extends the
pytest_pycollect_makeitemhook to mark Hypothesis tests whose function body is a coroutine.Closes #258
I was uncertain whether to add the tests to the auto mode tests or to the Hypothesis tests. I eventually decided to add them to the tests for the Hypothesis integration. Rather than using
pytesterI added some assertions so the tests would fail in case we ever changeasyncio_modeto something other than auto. Let me know what you think of this.