Registry / testing / pytest-lazy-fixture

pytest-lazy-fixture

JSON →
library0.6.3pypypi✓ verified 25d ago

pytest-lazy-fixture is a plugin for the pytest testing framework that allows users to pass fixtures as values directly within `pytest.mark.parametrize` decorators. This simplifies test parameterization by enabling the reuse of fixtures where direct fixture injection is not typically supported. The current version is 0.6.3, but the library is no longer actively maintained and has known compatibility issues with newer pytest versions.

pip install pytest-lazy-fixture
INSTALL
IMPORT
SIG · PYTEST-LAZY-FIXTUR
P
pytest-lazy-fixture
testingpythonv0.6.3
Install
2.6s avg
Import
408ms
Disk
30MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.3 · 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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.432s · 31.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.6s · import 0.384s · 32MB
30MB installed
● package 30MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

lazy_fixture
from pytest_lazyfixture import lazy_fixture
This is the primary function used to wrap fixture names for parameterization.

This quickstart demonstrates how to use `lazy_fixture` to pass the return value of `my_fixture` as a parameter to `test_example` using `pytest.mark.parametrize`.

import pytest from pytest_lazyfixture import lazy_fixture @pytest.fixture def my_fixture(): return 'Hello from fixture!' @pytest.mark.parametrize('param_arg', [lazy_fixture('my_fixture')]) def test_example(param_arg): assert param_arg == 'Hello from fixture!' # To run this, save as a .py file (e.g., test_lazy.py) and run 'pytest'
Debug
Known issues
breakingpytest-lazy-fixture is incompatible with pytest versions 8.0.0 and newer. Attempting to use it with these versions will lead to test failures.
fix
Downgrade pytest to a version below 8.0.0 (e.g., `pytest==7.3.2`) or consider migrating to an actively maintained alternative like `pytest-lazy-fixtures` (note the 's').
affects: pytest >= 8.0.0
deprecatedThe `pytest-lazy-fixture` library is no longer actively maintained. This means new features, bug fixes, or compatibility updates for newer pytest versions are unlikely.
fix
It is highly recommended to migrate to `pytest-lazy-fixtures` (note the 's'), which is a community-maintained fork offering similar functionality and active development. Alternatively, consider using `request.getfixturevalue` for basic cases or redesigning tests to avoid this pattern if possible.
affects: All versions
gotchaFixtures used with `lazy_fixture` are resolved during test execution, not at collection time. This means you cannot use `lazy_fixture` to define parameters that are evaluated during the pytest collection phase for certain advanced scenarios.
fix
Be aware of the execution timing. If you need fixture values to influence test collection or other pre-execution steps, `lazy_fixture` is not the appropriate tool.
affects: All versions
breakingVersion 0.4.0 introduced a requirement for `pytest >= 3.3.0`. Older pytest versions will not be compatible with `pytest-lazy-fixture` versions 0.4.0 and above.
fix
Ensure your pytest version is 3.3.0 or higher when using pytest-lazy-fixture >= 0.4.0.
affects: < 0.4.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pytest_lazy_fixture'
The 'pytest-lazy-fixture' package has not been installed in the current Python environment.
fix
pip install pytest-lazy-fixture
NameError: name 'lazy_fixture' is not defined
The 'lazy_fixture' function was used within 'pytest.mark.parametrize' without being imported from 'pytest_lazy_fixture'.
fix
from pytest_lazy_fixture import lazy_fixture
AttributeError: type object 'LazyFixture' has no attribute '__qualname__'
pytest-lazy-fixture relies on internal pytest APIs that changed in pytest versions 7.x and later, leading to incompatibility when pytest tries to introspect the LazyFixture object.
fix
Downgrade pytest to a compatible version (e.g., pytest<7.0.0), or migrate to actively maintained alternatives like pytest-cases.
TypeError: object of type 'LazyFixture' has no len()
pytest attempts to treat the LazyFixture object directly as an iterable or sequence (e.g., by calling len()), rather than resolving it to its underlying fixture value. This often indicates a compatibility issue with the pytest version or incorrect usage within parametrize.
fix
Ensure pytest is a version compatible with pytest-lazy-fixture (e.g., pytest<7.0.0). Verify that lazy_fixture is used correctly as an individual item within the parameter list.
AttributeError: module '_pytest.mark.structures' has no attribute 'CallSpec2'
`pytest-lazy-fixture` relies on internal `pytest` APIs (`_pytest.mark.structures.CallSpec2`) that were removed or significantly changed in `pytest` version 7.0 and newer, leading to incompatibility.
fix
Downgrade `pytest` to a version older than 7.0 (e.g., `pip install pytest<7.0`). Alternatively, rewrite tests to avoid `pytest-lazy-fixture` as it is unmaintained.
Upgrade
Version history
0.6.3latest on PyPI · released Feb 1, 2020
Audit
Dependencies
pytestrequiredCore testing framework; 'pytest-lazy-fixture' is a plugin for it.
Agent activity
10 hits · last 30 days
node
8
Resources
pytest-lazy-fixture — pip install pytest-lazy-fixture · libregistry