Skip to content

PT019 should not recommend usefixtures for parametrize values #17599

@Hawk777

Description

@Hawk777

Summary

Consider the following code:

import pytest

@pytest.mark.parametrize("_foo", [1, 2, 3])
def test_thingy(_foo):
    print("hello")

When I run ruff check --select=PT019 on it, it fails. However, according to a pytest dev replying to my question here, a value injected via parametrize is a fixture only due to an implementation detail that should not be relied upon. Therefore, it is inappropriate to use @pytest.mark.usefixture on it.

Version

ruff 0.11.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedContributions especially welcomeruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions