Skip to content

Add support for dictionary argvalues for parametrize #5487

Description

@kevinjfoley

I'd like to be able to pass a dictionary to pytest.mark.parametrize as argvalues with the keys as ids and the values as argvalues

For example:

import pytest


@pytest.mark.parametrize(["a", "b"], {"test 1": (1, 2), "test 2": (3, 4)})
def test_foo(a, b):

    assert a + 1 == b

# instead of
@pytest.mark.parametrize(["a", "b"], [(1, 2), (3, 4)], ids=["test 1", "test 2"])
def test_foo(a, b):

    assert a + 1 == b

would generate two tests named "test 1" and "test 2".

Before trying to add this feature I wanted to make sure there's no foreseen issues with a making change like this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: parametrizerelated to @pytest.mark.parametrizetype: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions