Skip to content

Static fixture closure for an item does not properly consider overridden fixtures #13773

@bluetech

Description

@bluetech

Via pytest-dev/pytest-django#1246.

The statically-computed fixture closure of a test item doesn't properly handle transitive dependencies through overridden fixtures, as demonstrated in the failing test below:

import pytest

@pytest.fixture
def db(): pass

@pytest.fixture
def app(db): pass

class TestClass:
    # Overrides module-level app, doesn't request `db` directly, only transitively.
    @pytest.fixture
    def app(self, app): pass

    def test_something(self, request, app):
        # Dynamic fixture closure calculated during run phase. Works.
        assert 'db' in request.fixturenames
        # Static fixture closure calculated during collection phase. Fails, but should work.
        assert 'db' in request.node.fixturenames

Metadata

Metadata

Assignees

Labels

topic: fixturesanything involving fixtures directly or indirectlytype: bugproblem that needs to be addressed

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions