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
Refactor pytest_pycollect_makeitems #421
Merged
seifertm
merged 9 commits into
pytest-dev:master
from
seifertm:refactor-pytest-collection-makeitems
Oct 11, 2022
Merged
Refactor pytest_pycollect_makeitems #421
seifertm
merged 9 commits into
pytest-dev:master
from
seifertm:refactor-pytest-collection-makeitems
Oct 11, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…collection_modifyitems. pytest_pycollect_makeitem currently calls `Collector._genfunctions`, in order to delegate further collection of test items to the current pytest collector. It does so only to add the asyncio mark to async tests after the items have been collected. Rather than relying on a call to the protected `Collector._genfunctions` method the marking logic was moved to the pytest_collection_modifyitems hook, which is called at the end of the collection phase. This change removes the call to protected functions and makes the code easier to understand. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…ction items. pytest_collection_modifyitems has no effect when asyncio mode is not set to AUTO. Moving the mode check out of the loop prevents unnecessary work. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…o_mark to _make_asyncio_fixture_function and _is_asyncio_fixture_function, respectively. The new names reflect the purpose of the functions, instead of what they do. The new names also avoid confusion with pytest markers by not using "mark" in their names. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
Legacy mode has been removed, so we don't need an elif to check if we're in AUTO mode. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
… to "processed_fixturedefs" to better reflect the purpose of the variable. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
It is safe to call _make_asyncio_fixture_function without checking whether the fixture function has been converted to an asyncio fixture function, because each fixture is only processed once in the loop. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
Merged two if-clauses both of which cause the current fixturedef to be skipped. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…ixtures in order to improve readability. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…_fixtures in order to improve readability. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pytest-asyncio essentially performs custom collection logic in
pytest_pycollect_makeitem
. This PR splits up the handling of async fixtures and async tests during test collection, renames a couple of thins, and extracts more fine-grained functions from_preprocess_async_fixtures
. The goal of this PR is to make the code easier to understand.This is a result of my investigation into #204.