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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 787833087014b65eb622a16f3cc9a89a4ceccc5ba3f97df9ba8bd086e98c19a4 |
|
MD5 | a6c4fa1cf6dd415d08702faed0038071 |
|
BLAKE2b-256 | 4fdf16a22a4ad35784f0e303d42dd5323704157b9d31a3e978f26d15cb10cbad |
Close
Hashes for pytest_lazy_fixture-0.5.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 282fe28124eb1478e889088b3f616958caf7ac4cfc86f073b9ded6e2e6675c07 |
|
MD5 | 6cef0dfb5647f526cf9e05d88e197aa0 |
|
BLAKE2b-256 | d1c297222a4d24f5befac7535e1096e7effc724f8578afebf03465b407031bb9 |