Allows you to use fixtures in @pytest.mark.parametrize.
Maintained. Last release 4 months ago, commits in 1 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install pytest-lazy-fixturespytest-lazy-fixtures
Use your fixtures in @pytest.mark.parametrize.
This project was inspired by pytest-lazy-fixture.
Improvements that have been made in this project:
- You can use fixtures in any data structures
- You can access the attributes of fixtures
- You can use functions in fixtures
- It is compatible with pytest-deadfixtures
Installation
pip install pytest-lazy-fixtures
Usage
To use your fixtures inside @pytest.mark.parametrize you can use lf (lazy_fixture).
import pytest
from pytest_lazy_fixtures import lf
@pytest.fixture()
def one():
return 1
@pytest.mark.parametrize('arg1,arg2', [('val1', lf('one'))])
def test_func(arg1, arg2):
assert arg2 == 1
lf can be used with any data structures. For example, in the following example, lf is used in the dictionary:
import pytest
from pytest_lazy_fixtures import lf
@pytest.fixture()
def one():
return 1
@pytest.mark.parametrize('arg1,arg2', [('val1', {"value": lf('one')})])
def test_func(arg1, arg2):
assert arg2 == {"value": 1}
You can also specify getting an attribute through a dot:
import pytest
from pytest_lazy_fixtures import lf
class Entity:
def __init__(self, value):
self.value = value
@pytest.fixture()
def one():
return Entity(1)
@pytest.mark.parametrize('arg1,arg2', [('val1', lf('one.value'))])
def test_func(arg1, arg2):
assert arg2 == 1