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.

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.

@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.