Skip to content

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

@nschloe

Description

@nschloe

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: parametrizerelated to @pytest.mark.parametrizetype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions