types-pytest-lazy-fixture

raw JSON →
0.6.3.20260408 verified Mon Apr 27 auth: no python

Typing stubs for pytest-lazy-fixture, providing type hints for LazyFixture and lazy_fixture. Current version 0.6.3.20260408, updated via typeshed. Low release cadence; updated with typeshed releases.

pip install types-pytest-lazy-fixture
error ModuleNotFoundError: No module named 'pytest_lazyfixture'
cause Missing runtime package; the stubs do not provide the actual module.
fix
Install the runtime package: pip install pytest-lazy-fixture
error ImportError: cannot import name 'LazyFixture' from 'pytest'
cause LazyFixture is not exposed from pytest; it's internal.
fix
Use from _pytest.compat import LazyFixture or avoid importing it directly.
error TypeError: lazy_fixture() missing 1 required positional argument: 'name'
cause lazy_fixture expects a string fixture name, not a fixture function.
fix
Pass the fixture name as a string: lazy_fixture('my_fixture')
gotcha Do not import LazyFixture from pytest; it is not part of the public API. It lives in _pytest.compat. The stubs in types-pytest-lazy-fixture rely on that internal path.
fix Use from _pytest.compat import LazyFixture if you need the type, but prefer using lazy_fixture from pytest_lazyfixture.
gotcha The package name is 'pytest-lazy-fixture' (with hyphens), but the Python import uses underscores: pytest_lazyfixture. Using the wrong import leads to ModuleNotFoundError.
fix Install via 'pip install pytest-lazy-fixture' (hyphens), then import as 'from pytest_lazyfixture import lazy_fixture' (underscores).
deprecated The original pytest-lazy-fixture project is unmaintained (last release 2020). types-pytest-lazy-fixture only provides type stubs, not the runtime package. Ensure you also install the runtime package.
fix Install both: pip install pytest-lazy-fixture types-pytest-lazy-fixture

Basic usage of lazy_fixture with parametrize. Note: types-pytest-lazy-fixture provides stubs for this pattern.

from typing import Generator
import pytest
from pytest_lazyfixture import lazy_fixture

def fixture_one() -> int:
    return 1

def fixture_two(request) -> int:
    return 2

@pytest.mark.parametrize(
    'arg',
    [
        lazy_fixture('fixture_one'),
        lazy_fixture('fixture_two'),
    ]
)
def test_lazy(arg: int) -> None:
    assert arg in (1, 2)