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

multiple mark.parametrize with tuples: ValueError: indirect given to [...] #3644

Closed
nschloe opened this issue Jun 30, 2018 · 3 comments
Closed
Labels
topic: parametrize related to @pytest.mark.parametrize type: bug problem that needs to be addressed

Comments

@nschloe
Copy link
Contributor

nschloe commented Jun 30, 2018

Combining multiple mark.parametrize is easy. Just go

import pytest

@pytest.mark.parametrize('foo', ['a', 'b', 'c'])
@pytest.mark.parametrize('bar', [1, 2, 3])
def test_things(foo, bar):
    assert foo in ['a', 'b', 'c']
    assert bar in [1, 2, 3]

However, this fails if one of the two parametrizations covers more than one argument. This

import pytest

@pytest.mark.parametrize('foo', 'bar', [('a', 1), ('b', 2), ('c', 3)])
@pytest.mark.parametrize('baz', [4, 5, 6])
def test_things(foo, bar, baz):
    assert foo in ['a', 'b', 'c']
    assert bar in [1, 2, 3]
    assert baz in [4, 5, 7]

fails with error

E   ValueError: indirect given to <function test_things at 0x7f3c2881e2f0>: fixture ('a', 1) doesn't exist

This is with

$ pytest --version
This is pytest version 3.6.2, imported from /path/to/pytest.py
@pytestbot pytestbot added the topic: parametrize related to @pytest.mark.parametrize label Jun 30, 2018
@pytestbot
Copy link
Contributor

GitMate.io thinks possibly related issues are #815 (Combining multiple @pytest.mark.parametrize lines), #1111 (pytest.mark.parametrize fails with lambdas), #328 (@pytest.mark.parametrize not working with tuple as advertized in docs), #2404 (Class decorator marks multiple classes), and #213 (Issue with numpy arrays and pytest.mark.parametrize).

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 30, 2018
@nschloe
Copy link
Contributor Author

nschloe commented Jun 30, 2018

Ah, a typo.

@pytest.mark.parametrize('foo', 'bar', [('a', 1), ('b', 2), ('c', 3)])

should be

@pytest.mark.parametrize('foo, bar', [('a', 1), ('b', 2), ('c', 3)])

@nschloe nschloe closed this as completed Jun 30, 2018
@RonnyPfannschmidt
Copy link
Member

this deserves a followup since the triggered error is so missleading, i will open a issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: parametrize related to @pytest.mark.parametrize type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

3 participants