-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fix pytest.parametrize when argnames are specified as kwarg #2819
Fix pytest.parametrize when argnames are specified as kwarg #2819
Conversation
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.
please also include a test for the behaviour
_pytest/fixtures.py
Outdated
# skip directly parametrized arguments | ||
argnames = func_params[0] | ||
if "argnames" in parametrize_func.kwargs: |
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 line directly breaks testing pytest in various cases, see the broken ci results
the defensive coding in the surrounding lines may look ludicrous, but python doesn't have monadic handling of defensive coding so we have to bite the bullet or include null types
Thanks @RonnyPfannschmidt . Please have a look at the updated version. I also added a test case. Turns out the bug is only triggered when parameterizing a test that relies on a parameterized fixture..
|
43ef7d3
to
e86ba41
Compare
Previously only this worked:
@pytest.mark.parametrize("A", argvalues=[(A1, ), (A2, )])
Now argnames can be specified explicitly:
@pytest.mark.parametrize(argnames="A", argvalues=[(A1, ), (A2, )])