-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
pytest_generate_tests cannot modify fixtures of parametrized tests #4017
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
Comments
I also tried specifying |
this is a sife-effect of introducing the definition note to get access to markers in metafunc -now you suddenly no longer get sway with mutating random state from my pov this is a unplanned api change that we might want to document, but certainly not revert since you use-case isnt clear for whole modules you can just do |
I'm aware of The problem is that importing Qt4 stops importing from Qt5 and vice versa. So if there's a module level |
in that case i would propose using a opt-in skip at the module level (you can do a full module skip) to see to a good backend structure things might take a bit longer if you do have backend abstraction, then ideally you use it for tests instead of having one file per backend (that way backend selection cna be done at the test strart) however such an "pure" concept might simply not fit practical application in the code as it is right now |
Looking at this example, I think adding something like this to @pytest.fixture(autouse=True)
def settings(should_skip, settings):
pass works to tweak the order. Is that something that might be stable? |
its not clear to me what fits well as i currently don't have the time to gather all the context needed to read the mathplotlib in a understanding manner |
Yes, |
This one is related tto making ffunctiondefinition part of the collection ttree |
Follow-up to #2522 then? |
Yup |
(I added this to the "detangle node structure" project) |
In Matplotlib, we have a general autouse fixture that may or may not load a backend (i.e., UI toolkit) that causes a fatal error (if it doesn't exist), depending on test markers. In an effort to avoid that, I tried to add a fixture that skips tests that might use an unavailable backend. Because file-specific fixtures run after those in
conftest.py
, I usedpytest_generate_tests
to implement it, but this no longer seems to work on parametrized tests.For the sake of an example, start with an autouse fixture that always fails in
conftest.py
:then in
test_foo.py
, a fixture that should skip the test, inserted first viapytest_generate_tests
so that it occurs before the above exception:This works for
test_foo
;should_skip
is called first and the remaining fixtures are skipped.If I then add a parametrized test:
all of these call
settings
first instead ofshould_skip
. The printout shows thatshould_skip
is no longer in the list of fixtures either.This used to work in pytest 3.6.3, but fails in 3.7.0. I bisected the issue back to #3629, but I'm not sure exactly if that intended for this behaviour to change.
$ pip list
Package Version Location
execnet 1.5.0
py 1.6.0
pytest 3.6.3.dev34+g1dc5e97a
pytest-cov 2.6.0
pytest-faulthandler 1.5.0
pytest-flake8 1.0.2
pytest-forked 0.2
pytest-rerunfailures 4.1
pytest-xdist 1.23.0
The text was updated successfully, but these errors were encountered: