It helps to use fixtures in pytest.mark.parametrize
Project description
Use your fixtures in @pytest.mark.parametrize.
Installation
pip install pytest-lazy-fixture
Usage
import pytest
@pytest.fixture(params=[1, 2])
def one(request):
return request.param
@pytest.mark.parametrize('arg1,arg2', [
('val1', pytest.lazy_fixture('one')),
])
def test_func(arg1, arg2):
assert arg2 in [1, 2]
Also you can use it as a parameter in @pytest.fixture:
import pytest
@pytest.fixture(params=[
pytest.lazy_fixture('one'),
pytest.lazy_fixture('two')
])
def some(request):
return request.param
@pytest.fixture
def one():
return 1
@pytest.fixture
def two():
return 2
def test_func(some):
assert some in [1, 2]
Please see tests for more examples.
Contributing
Contributions are very welcome. Tests can be run with tox.
License
Distributed under the terms of the MIT license, pytest-lazy-fixture is free and open source software
Issues
If you encounter any problems, please file an issue along with a detailed description.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for pytest-lazy-fixture-0.5.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fe84f0853b96e2da5b2056011b06abf27f68cc610e60b93ea07cb3b0d2e4c34 |
|
MD5 | 73ef5749654dd807680df9dc6c062869 |
|
BLAKE2b-256 | 9a501a8b5d6ca7ac7c404aa6211603be3c17d622d8d2c126466f8c92f2872b3c |
Close
Hashes for pytest_lazy_fixture-0.5.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a39e20e284fa89ab1c49a9638eb42e31352b27bb9b28ef43c20c8742fb45e22 |
|
MD5 | 1f66252fa411fed557b84db7f24cf37e |
|
BLAKE2b-256 | 03ffe8414bbcacdd670b5e58e1381c8f8f1c2de0f93c103593c25a2fc7df2e38 |