Skip to content

calling pytest.Metafunc.parametrize multiple times #11289

@calestyo

Description

@calestyo

Hey.

I think this is at least a documentation ambiguity. ;-)

pytest/src/_pytest/python.py

Lines 1242 to 1249 in cc0adf6

Can be called multiple times, in which case each call parametrizes all
previous parametrizations, e.g.
::
unparametrized: t
parametrize ["x", "y"]: t[x], t[y]
parametrize [1, 2]: t[x-1], t[x-2], t[y-1], t[y-2]

AFAIU however, this can be only called multiple times on different parameters.

Otherwise I get a:

ERROR test_foo.py - ValueError: duplicate 'cal'
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

I stumbled over this while trying what what I've asked for on discord... maybe the behaviour there is another bug, but maybe some pytest expert can look at it and confirm whether it's fishy... I'm still basically a complete pytest beginner... so I don't wanna file issues for everything that seems just strange to me ;-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions