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.6.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50d02e7dfad719948efee6bb060fa13e85f11688f78243a468406110ebc06284 |
|
MD5 | a2662cd3baa35c0ac3e8e13333e87c9b |
|
BLAKE2b-256 | 9096c75347d43a3e288eb194e2e5948fb3f1257acc52afe19df1bb2dc7e39510 |
Close
Hashes for pytest_lazy_fixture-0.6.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4a6263c7ca3cc04d1f7950921b0d4bdac8062ae10c0c4295bf3e0638526102c |
|
MD5 | bfb0cfb43433264ff22b142e0efce42d |
|
BLAKE2b-256 | ede6517dc99debebd91e842f2c9751bcaa9a0859d6dd0f3d9477941657589e6f |