Pytest fixtures marked as unused

Make sure to read this post before raising a thread here:

@pytest.fixture
def fixture():
    """does something internally"""

def test_fixture(fixture):
    assert 1 + 1 == 2

result:

class VarTest:
    __var: int

    @property
    def var(self) -> int:
        return self.__var

    @pytest.fixture(autouse=True)
    def __var_injector(self):
        self.__var = random.randint(0, 100)

result:

Fixtures may do something internally. So assumption, that these 2 examples have unused variables is wrong.

Hey there.

As in your previous post:

Hello @Grzegorz_Ryznar,

First, thank you for reporting the false positive.
We already noticed it and fixed it in this ticket. I see you’re using SonarLint in PyCharm. As far as I know, the latest version doesn’t embed the fix, but the next one that should be released in the next few weeks will.

Hope that helps,
Guillaume

Great! Thanks for the response! But after acquaintance with this issue on Jira I’ve noticed that second problem(autoused fixture) is not covered. Will this fix cover that too?