-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat - use fixture plugins instead of conftest files #2816
Conversation
Nice initiative! Is this a common pattern? And can we still rely on pytests "auto" import of fixtures? |
It looks nicely structured and seems like to improve the ability to lookup fixtures more easily. It would be great to expand this ot other modules. If we can retain all other functionality, maybe the tests/conftest.py will end up containing only imports. |
I love it! As long as the auto imports work, I love it. |
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.
Looks like a great improvement!
I know requesting plugins in the root contest is a common approach, but honestly I am not sure how common it is to request fixtures. The documentation does mention fixtures but very briefly https://docs.pytest.org/en/7.2.x/how-to/writing_plugins.html#requiring-loading-plugins-in-a-test-module-or-conftest-file. We can rely on the fixtures to be loaded automatically, it is equivalent to writing them down on the root conftest |
Exactly. It is still left to discuss if we would like a hybrid approach with some fixtures in the contests (that could be very specific and only used in one test) or a fixture structure purely based on plugin requests |
The full migration to plugins will be done in several PRs |
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 really like the new structure, it is much easier to see and understand what fixtures we are working with!
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.
This looks great! ⭐
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
Description
Fix #2095 and continue #2259.
TL;DR
The main
conftest.py
was too crowded, now the fixtures are separated into different modules available to all tests.Details
The current test system looks for fixtures defined in the
conftest.py
files, either in the local directory or in any directory above, but it is impossible to use a fixture defined in a directory below it. For example, a test function intest_module_top.py
can't access a fixture defined intests/subfolder/subsubfolder/conftest.py
:To solve this, we started writing all our fixtures in the first contest, i.e.
tests/conftest.py
. This made this file extremely crowded and difficult to navigate.This PR changes the conftest structure for a plugin structure, in which the fixtures are grouped by topic in a folder called
fixture_plugins
and imported in the conftest as a plugin. In this way, the structure of the tests isand both
test_module_top.py
andtest_module_sub.py
have access to all the fixtures defined infixture_plugins
.Added
tests/fixture_plugins/
with the following structure:Changed
conftest.py
to separate modules in the new fixture plugin directory.How to prepare for test
us
paxa
How to test
Expected test outcome
Review
Thanks for filling in who performed the code review and the test!
This version is a
Implementation Plan