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.4.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5674171e4c408b338dd178ba192bfb72f5468462f4242c7f83325bc4c7d6e5ea |
|
MD5 | 70b232442811f71746b567a09d896526 |
|
BLAKE2b-256 | 4ff69358397a0d1a99fa22313bb05be51280b7a98f474971fb0a820bab0945fb |
Close
Hashes for pytest_lazy_fixture-0.4.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2398240352b16cb9b59295821475ae983c8b015c97be8b8df21f2348f3885b9 |
|
MD5 | b2b64d3c63bc92af46f5218330647b76 |
|
BLAKE2b-256 | 9f2f6be42e288e265f9291a0c64cc80bf6e78088af94f7e4631f5363cfa705b8 |