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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e7d0c7f74ba33e6e80905e9bfd81f9d15ef9a790de97993e34213deb5ad10ac |
|
MD5 | d58a9fbd0ccee6903d8e2cce2b4c9e19 |
|
BLAKE2b-256 | b282ae6d2f6903719c4ec410dcd31ee24e3bce74b2cef3c5b9150ad36e8594b6 |
Close
Hashes for pytest_lazy_fixture-0.6.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0b379f38299ff27a653f03eaa69b08a6fd4484e46fd1c9907d984b9f9daeda6 |
|
MD5 | d4cc73680f20630f471965e4cc40694a |
|
BLAKE2b-256 | 2da12f2c1c2353350d66c4d110d283e422e4943eb5ad10effa9357ba66f7b5b9 |