Skip to content
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

IndexError occurs if pytest.mark.parametrize is used with keyword arguments. #2821

Closed
KillAChicken opened this issue Oct 8, 2017 · 2 comments

Comments

@KillAChicken
Copy link

Description
The names of the arguments for parametrization are determined only by positional arguments of pytest.mark.parametrize. It leads to the IndexError in the following code.

import pytest


@pytest.fixture(params=range(1))
def parametrized_fixture(request):
    return request.param


@pytest.mark.parametrize(argnames="parametrized_argument", argvalues=range(1))
def test_parametrization(parametrized_fixture, parametrized_argument):
    pass

while the tests with positional arguments work fine

import pytest


@pytest.fixture(params=range(1))
def parametrized_fixture(request):
    return request.param


@pytest.mark.parametrize("parametrized_argument", argvalues=range(1))
def test_parametrization(parametrized_fixture, parametrized_argument):
    pass

The issue is reproducible only with invokation of the pytest_generate_tests, thus parametrization works in case, when all the fixtures are parametrized by pytest.mark.parametrize decorator:

import pytest


@pytest.mark.parametrize(argnames="parametrized_argument", argvalues=range(1))
def test_parametrization(parametrized_argument):
    pass

Environment:
py (1.4.34)
pytest (3.2.3)

@RonnyPfannschmidt
Copy link
Member

this will be fixed by #2819 thanks to @leezu

@RonnyPfannschmidt
Copy link
Member

i just merged that one, the next feature/patch release will include it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants