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

Merged
merged 4 commits into from Oct 9, 2017

Conversation

Projects
None yet
3 participants
@leezu
Contributor

leezu commented Oct 8, 2017

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, )])

@RonnyPfannschmidt

please also include a test for the behaviour

# skip directly parametrized arguments
argnames = func_params[0]
if "argnames" in parametrize_func.kwargs:

This comment has been minimized.

@RonnyPfannschmidt

RonnyPfannschmidt Oct 8, 2017

Member

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

@coveralls

This comment has been minimized.

coveralls commented Oct 8, 2017

Coverage Status

Coverage decreased (-0.007%) to 92.224% when pulling e89abe6 on leezu:fix_kwargs_fixtures into 761d552 on pytest-dev:master.

leezu added a commit to leezu/pytest that referenced this pull request Oct 8, 2017

@leezu

This comment has been minimized.

Contributor

leezu commented Oct 8, 2017

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..

        import pytest

        @pytest.fixture(params=[1,2])
        def a(request):
            return request.param

        @pytest.mark.parametrize(argnames='b', argvalues=[1, 2])
        def test_func(a, b):
            pass

@coveralls

This comment has been minimized.

coveralls commented Oct 8, 2017

Coverage Status

Coverage increased (+0.003%) to 92.235% when pulling e86ba41 on leezu:fix_kwargs_fixtures into 761d552 on pytest-dev:master.

@coveralls

This comment has been minimized.

coveralls commented Oct 8, 2017

Coverage Status

Coverage increased (+0.003%) to 92.235% when pulling e86ba41 on leezu:fix_kwargs_fixtures into 761d552 on pytest-dev:master.

@RonnyPfannschmidt RonnyPfannschmidt merged commit 46e3043 into pytest-dev:master Oct 9, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

dirk-thomas added a commit to dirk-thomas/pytest that referenced this pull request Oct 11, 2017

dirk-thomas added a commit to dirk-thomas/pytest that referenced this pull request Oct 11, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment