Pytest Lazy Fixture

0.6.3 · deprecated · verified Sat Apr 11

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.

Warnings

Install

Imports

Quickstart

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'

view raw JSON →