-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Parameterized autouse fixtures don't work with unittest TestCase subclasses #3095
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
GitMate.io thinks the contributor most likely able to help you is @nicoddemus. |
Thanks @paultiplady for creating the issue! |
thats per design - unittest test classes do not participate in parametrization, we should have better warnings |
@RonnyPfannschmidt I asked @paultiplady to open this issue to separate it from the discussion about better messages in #2535 because I wanted to at least investigate the error. But you are right, they are not supported by design and probably won't be easy to just make them work. Let's leave it open for now, as soon as I have some time I want to take a look. |
(Btw, the issue is about parametrized- |
from the pytest side indirect parameterization via autouse fixtures and parameterization via direct means is the same, |
But the parametrization in this case is for the fixture, not for the test function. Given that |
all parameterization happens via generate_tests, which is not applied to legacy unittest functions |
I see, thanks for the explanation. @paultiplady, as @RonnyPfannschmidt explained the matter of this issue can't be done by design, so I'm closing this for now. The improvement to the error message is already being tracked in #2535. |
(Follow-up from discussion in #2535)
I'm trying to get parameterization to work with unittest TestCase tests. In the linked issue, it was suggested that since fixtures can be injected with
autouse
, it might be possible to inject parameterized fixtures withautouse
as well.Unfortunately this doesn't work:
Gives the error
Failed: The requested fixture has no parameter defined for the current test.
. This is the same error that's given if a normal fixture is injected into a unittest TestCase method.Full test output:
System details:
pip list
of the virtual environment you are usingThe text was updated successfully, but these errors were encountered: