Skip to content

Fixtures are not rebuilt when param changes for a fixture they depend on, if the dependency is via getfixturevalue #14103

Description

@Anton3

Minimal reproducer:

import pytest

@pytest.fixture(scope="session")
def foo(request):
    return request.param

@pytest.fixture(scope="session")
def bar(request):
    return request.getfixturevalue("foo")

@pytest.mark.parametrize("foo", [1], indirect=True)
def test_first(foo, bar):
    assert bar == 1

@pytest.mark.parametrize("foo", [2], indirect=True)
def test_second(foo, bar):
    assert bar == 2

test_second fails, because bar == 1.

The reason is that pytest currently only tracks static dependencies via argnames for the purposes of resetting dependent fixtures.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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