pytest_configure fixtures not showing so set global now no coverage #13142
Unanswered
msftcangoblowm
asked this question in
Q&A
Replies: 1 comment
-
With a basic pytest plugin, all the code is in one module without importing fixtures from other modules. In which case, coverage has no problem finding the fixtures. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Explain the issue
There are two pytest plugin implementations. plugin_v0 is well tested. plugin_v1 is the newer implementation which is not as mature. So a gradual transition is occurring which ends when plugin_v0 is eventually deprecated and removed.
In the interm, there are two implementations. Both working. (assume) Both with tests. Both having issues with coverage caused by changing the fixture scope from function to module using Python builtin
global
. Without changing the scope, the plugin is registered, but the fixtures are not found.Is there a better, coverage friendly, way to make imported fixtures found without using
global
.In
pyproject.toml
In
tests/conftest.py
In
tests/__init__.py
exists and is an empty fileIn
src/thisismypackage/plugin_wireframe.py
Assume there are tests covering
fixture[0-3]
The plugin is registered. Without the
global
lines, the fixtures are not foundglobal mypackage
is the main fixture, pytester calls the main pytest fixture which calls other fixtures.This works beautifully, but
coverage
isn't spotting the fixtures.Would like to ask the community whether or not there is a better way to do this without
global
Have searched
The above issue is tailored towards mature plugin authors, not basic plugin case.
Beta Was this translation helpful? Give feedback.
All reactions