Skip to content

Fixture Editor Integration

Enables deep integration of pytest fixtures into the IDE editor, making fixture names behave like normal Python symbols. BetterPy resolves fixture definitions with pytest-style precedence, then uses that model for navigation, completion, definition searches, hierarchy actions, renaming, and usages.

For the broader release overview of the shared fixture model, plugin support, dynamic fixture strings, typing, and inspections, see fixture-aware pytest support.

Fixture parameters resolve to the fixture definition that pytest would choose for that location.

# tests/conftest.py
@pytest.fixture
def user():
    return User("default")

# tests/api/conftest.py
@pytest.fixture
def user():
    return User("api")

# tests/api/test_users.py
def test_profile(user):
    assert user.name == "api"

In test_profile, Go to Declaration (⌘B / Ctrl+B) on user navigates to tests/api/conftest.py.

Typed parameter implementations

Go to Implementations (⌥⌘B / Ctrl+Alt+B) on a typed function parameter opens the concrete implementations of its declared class. This works for ordinary functions as well as pytest fixtures.

class Handler(ABC):
    @abstractmethod
    def handle(self): ...

class SyncHandler(Handler):
    def handle(self): ...

class AsyncHandler(Handler):
    def handle(self): ...

def dispatch(handler<caret>: Handler): ...

Invoking Go to Implementations on handler opens Choose Implementation of inferred type Handler and offers SyncHandler and AsyncHandler. The same inferred-type chooser is available on an injected fixture parameter when its fixture function declares that return type.

Completion

Fixture-name completion is available in test and fixture parameter lists. Suggestions include visible fixtures from the current file, imports, ancestor conftest.py files, and discovered plugin fixtures.

Cold completion returns available local or cached suggestions without waiting for complete discovery. Builtin, plugin, and parent-override fixtures may arrive in the cache later: continue typing or invoke completion again to see them. An untouched popup is not updated automatically, and background discovery never reopens a dismissed popup.

@pytest.fixture
def client(app):
    return app.test_client()

def test_health(cli<caret>):
    ...

Completion can suggest client and inserts it as a normal parameter. BetterPy skips names that are already controlled by @pytest.mark.parametrize, and it keeps self and cls out of fixture suggestions.

Rename And Usages

Renaming a fixture updates fixture parameters and known fixture references rather than only the Python function declaration. Find Usages (⌥F7 / Alt+F7) also treats fixture injections as usages, so a fixture can be audited before changing or deleting it.

@pytest.fixture
def api_client():
    return Client()

def test_status(api_client):
    assert api_client.get("/status").ok

Renaming api_client updates both the fixture definition and the injected parameter.

Override Hierarchy Support

Fixture definitions participate in IDE hierarchy workflows:

  • Go to Super from an overriding fixture opens the fixture it shadows in a broader scope.
  • Gutter markers on overridden fixtures list narrower-scope fixtures that override them.
  • Go to Type Declaration from a fixture parameter opens the fixture function that supplies the value.
  • Implement/Override Methods can offer fixture overrides when editing test classes that inherit fixture methods.