-
-
Notifications
You must be signed in to change notification settings - Fork 24
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Trio testing with Hypothesis #44
Conversation
Codecov Report
@@ Coverage Diff @@
## master #44 +/- ##
==========================================
- Coverage 95.7% 95.28% -0.42%
==========================================
Files 10 11 +1
Lines 256 276 +20
Branches 23 26 +3
==========================================
+ Hits 245 263 +18
- Misses 8 9 +1
- Partials 3 4 +1
Continue to review full report at Codecov.
|
@given(st.integers()) | ||
@pytest.mark.trio | ||
async def test_mark_inner(n): | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be interesting to add a isinstance(n, int)
check in the body just to be sure ?
@given(x=st.integers()) | ||
@pytest.mark.trio | ||
async def test_mark_and_parametrize(x, y): | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, but I would make the parametrize
and given
produce different types of data just to be sure we don't get x
and y
mixed
pytest_trio/plugin.py
Outdated
print(dir(item.obj)) | ||
if hasattr(item.obj, 'hypothesis'): | ||
# If it's a Hypothesis test, we go in a layer. We *don't* check | ||
# that this is a coroutine function, because we might have wrapped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned about the "might have wrapped", what happened if the test function is synchronous but wrapper in a hypothesis.given
? I would say we must always check the test function is async (because we will always call it async still and get a crash if it's not the case).
A simple solution I see is to move the check within _trio_test_runner_factory (given it is currently called just after the check it would change nothing, and it's pretty evident the parameter passed to this factory must be an async function)
test-requirements.txt
Outdated
@@ -1,2 +1,3 @@ | |||
pytest | |||
pytest-cov | |||
hypothesis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we add a >=3.64.0 rule to this requirement ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! You should probably add minimum versions to pytest and pytest-cov too then, as I'm sure there are some old enough that they don't work...
Thanks for the PR, I'm really eager to merge this one 馃槂 |
2e59925
to
ccd5ec2
Compare
馃挴 Great 馃 job 馃帀 @Zac-HD 馃嵕 ! |
Thanks, and welcome! 馃帀 馃巶 No pressure, but if you'd like to keep contributing then we'd love to have you, so I'm sending you a github invite now. You can read more about this in our contributing documentation. |
I'm delighted to be on the team, and will certainly hang around! Also delighted by the contributing docs - they're excellent, congrats 馃帀 |
Closes #42, based on my work upstream in HypothesisWorks/hypothesis#1343.
CC @njsmith and @zmitchell - note that you'll need a recent version of Hypothesis as the mechanism to support this was literally released yesterday! It's public API and perfectly stable though, agreeing on a design we liked enough to support long-term is the main thing that took us so long 馃槃