Skip to content

python: a class that overrides a module-level fixture still has its tests credited to the module fixture #1512

Closed

Description

@swapnilpaliwal-sd

Symptom

A class that overrides a module-level pytest fixture of the same name still has its tests credited to the module fixture.

Reproduction

app/__init__.py (empty), app/accounts.py:

def module_account(): return "module"
def class_account(): return "class"

tests/test_accounts.py:

import pytest
from app.accounts import class_account, module_account

@pytest.fixture
def account():
    return module_account()

class TestOverride:
    @pytest.fixture
    def account(self):
        return class_account()
    def test_in_class(self, account):
        assert account == "class"

class TestPlain:
    def test_no_override(self, account):
        assert account == "module"

def test_module_level(account):
    assert account == "module"

axiomcode impact app/accounts.py:1 --tests prints 3 of 3 ... via account: TestOverride::test_in_class, TestPlain::test_no_override, test_accounts.py::test_module_level. pytest serves test_in_class from TestOverride.account only. The control, impact app/accounts.py:2 --tests, is right: 1 of 3 ... TestOverride::test_in_class. The MCP axiomcode_impact tool answers the same.

Root cause

plugins/axiomcode/skills/axiomcode/scripts/dl/impact.dl:825-826: a fixture with no owner (!owner(fx, _)) is matched to every test in its path scope that takes the parameter name. Nothing checks whether a same-named fixture on the test's own class, or a base class, shadows it.

Expected: impact app/accounts.py:1 --tests lists TestPlain::test_no_override and test_module_level only.

Measured on 0.1.3 at 0df257c.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpythonPythonskillAgent-facing query skill (skills/axiomcode)

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions