-
Notifications
You must be signed in to change notification settings - Fork 85
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
test: Discover pytest fixtures during doctest #2017
Conversation
* Symlink the tests/conftest.py under the src tree to allow for the autouse pytest fixtures to be discovered and used during doctest. This is needed as the backends are not currently being automatically reset between doctests and the fixtures will not be discovered during doctest runs invoked with `pytest src/` as noted in the pytest docs: > Note that like the normal conftest.py, the fixtures are discovered in the > directory tree conftest is in. Meaning that if you put your doctest with > your source code, the relevant conftest.py needs to be in the same directory > tree. Fixtures will not be discovered in a sibling directory tree! - c.f. https://docs.pytest.org/en/7.1.x/how-to/doctest.html#doctest-namespace-fixture * Exclude src/conftest.py from the MANIFEST.in so as to not include it in the sdist build.
a40ca09
to
eaa9b04
Compare
Codecov ReportBase: 98.28% // Head: 98.28% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## master #2017 +/- ##
=======================================
Coverage 98.28% 98.28%
=======================================
Files 68 68
Lines 4482 4482
Branches 730 730
=======================================
Hits 4405 4405
Misses 45 45
Partials 32 32
Flags with carried forward coverage won't be shown. Click here to find out more. Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Does this work if we move |
I think so (testing now) edit: NOPE. Assuming so, you'd prefer to have |
It feels a bit weird and hacky but I guess I see why. I wonder if |
Yeah, it is not ideal I agree. Though turns out we don't want to move c.f. the pytest docs for more details on the mechanics of
Yes, that's one of the reasons I wanted to split this out instead of putting it in PR #1274 so that |
Description
Symlink the
tests/conftest.py
under thesrc
tree to allow for the autouse pytest fixtures to be discovered and used during doctest. This is needed as the backends are not currently being automatically reset between doctests and the fixtures will not be discovered during doctest runs invoked withpytest src/
as noted in the pytest docs:Exclude
src/conftest.py
from theMANIFEST.in
so as to not include it in the sdist build.Checklist Before Requesting Reviewer
Before Merging
For the PR Assignees: