Skip to content

Testing (Pytest)

BetterPy's largest feature group — 1 features that supercharge your pytest workflow with fixture management, fixture inspections, parametrize helpers, mocking support, assertions, and test tree navigation.


Fixtures

BetterPy provides first-class, deep integration for pytest fixtures, refactorings, inspections, and documentation directly inside the IDE.

Pytest fixture documentation

Since 2026.05.2 · Maturity Stable · Issues PY-66245

Enhances Quick Documentation and member type inference for pytest fixtures across files.

Quick Documentation on a fixture or fixture parameter shows the resolved fixture type, dataclass/Pydantic/TypedDict fields, attribute docstrings, and literal values returned or yielded by simple fixtures. List, tuple, set, and dict literals are rendered across multiple lines so nested fixture data is easier to scan.

Supported fixture cases:

  • Primitive return types such as str, bool, list, dict, set, int, and float.
  • Generator-style fixtures annotated as Generator[T, ...], Iterator[T], Iterable[T], and their async variants; BetterPy documents and infers the yielded value type T.
  • Dataclasses, Pydantic models, and TypedDicts, including inherited fields, default values, and attribute docstrings.
  • Fixtures defined in conftest.py, including fixtures whose returned class is declared inside the fixture body.
  • The built-in request fixture, which is typed as _pytest.fixtures.SubRequest when available.

Parametrized test arguments are ignored because they shadow fixtures with the same name.

How to invoke: F1 / Ctrl+Q on a fixture parameter.

Example:

import pytest


@pytest.fixture
def api_config() -> dict:
    return {
        "base_url": "https://api.example.test",
        "headers": {"Accept": "application/json"},
        "timeouts": [1, 5, 10],
    }


def test_client(api_config):
    ...

Quick Documentation shows the fixture type and the returned dictionary value as a multiline block, including nested dictionaries and lists.