Install & Compatibility
Where this runs
tested against v1.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.036s · 31.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.7s · import 0.034s · 32MB
30MB installed
● package 30MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
lazy_fixture
✓ from pytest_lazy_fixtures import lazy_fixture
✗ from pytest_lazyfixtures import lf
lf
✓ from pytest_lazy_fixtures import lf
✗ from pytest_lazyfixtures import lf
lazy_fixture_callable
✓ from pytest_lazy_fixtures import lazy_fixture_callable
✗ from pytest_lazyfixtures import lf
This quickstart demonstrates the basic usage of `lf` (lazy_fixture) to inject a fixture's return value directly into `pytest.mark.parametrize`. It also shows how to use `lf` with complex data structures like dictionaries and how to access attributes of a fixture's return value using dot notation.
import pytest
from pytest_lazyfixtures import lf
@pytest.fixture()
def my_fixture_value():
return 'Hello from fixture!'
@pytest.mark.parametrize('param_name', [lf('my_fixture_value')])
def test_example(param_name):
assert param_name == 'Hello from fixture!'
# Example with a dictionary and attribute access
class MyObject:
def __init__(self, value):
self.value = value
@pytest.fixture()
def an_object():
return MyObject(42)
@pytest.mark.parametrize('data', [
{'key': lf('my_fixture_value')},
{'number': lf('an_object.value')}
])
def test_complex_data(data):
if 'key' in data:
assert data['key'] == 'Hello from fixture!'
if 'number' in data:
assert data['number'] == 42
Debug
Known issues
breakingBe aware of two similarly named packages: `pytest-lazy-fixture` (singular) and `pytest-lazy-fixtures` (plural). The singular version is older and often incompatible with `pytest` versions 8.0.0 and newer. Ensure you are installing and importing from `pytest-lazy-fixtures` to avoid compatibility issues and to use the actively maintained library.fixUse `pip install pytest-lazy-fixtures` and `from pytest_lazyfixtures import lf`.
affects: pytest-lazy-fixture (singular) with pytest >= 8.0.0. pytest-lazy-fixtures (plural) is unaffected by this specific incompatibility.
gotchaStarting with version 1.4.0, `lfc` (lazy_fixture_callable) supports implicit fixture injection. If a callable's parameter name matches a fixture name, the fixture will be resolved and passed automatically, provided no explicit value or default is present for that parameter. This might lead to unexpected fixture resolution if not fully understood.fixExplicitly use `lf()` for parameters where implicit injection is not desired, or ensure parameter names do not clash with fixture names if implicit injection is to be avoided. The documentation recommends implicit injection as the standard behavior for `lfc`.
affects: >=1.4.0
gotchaWhen using fixtures within complex data structures (e.g., dictionaries, lists) passed to `@pytest.mark.parametrize`, or when a fixture itself depends on another fixture that needs to be resolved, always wrap the fixture name with `lf()` to ensure proper resolution. Directly passing string names will not work and the fixture will not be evaluated.fixUse `lf('my_fixture')` instead of `'my_fixture'` when embedding fixtures in parameterized data or when a nested fixture needs to be resolved. affects: All versions
gotchaAvoid relying on `pytest.lazy_fixture` if placed directly in `conftest.py` or at the top level of a test file, as pytest's plugin loading order might cause `pytest.lazy_fixture` (a global attribute added by the plugin) to not exist during early fixture registration. Always import `lf` (or `lazy_fixture` for explicit aliasing) directly from `pytest_lazyfixtures` in all files where it's used.fixUse `from pytest_lazyfixtures import lf` in `conftest.py` and other test files where `lf` is needed.
affects: All versions
Upgrade
Version history
1.4.1latest on PyPI · released Aug 12, 2026
Audit
Dependencies
pytestrequiredCore testing framework integration, as it's a plugin for pytest.
pythonrequiredRequires Python 3.8 or newer.