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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 542a5a1d7fbfe43857187e41c797b45a9f81aa5143882651fd52dc61ef834694 |
|
MD5 | 8c11f4e39a4ffb4749093ef04c003373 |
|
BLAKE2b-256 | 47daf1ce350daec48c8cb9fa6bfaac563a63f77057b73eab8d4812b46a4f6133 |
Close
Hashes for pytest_lazy_fixture-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8812fcdf26d5ea8b8c3127d8000e6caf17be98a406119f13faf4623f3597266 |
|
MD5 | 2b48620e5a1b25ccbf5fe16174609981 |
|
BLAKE2b-256 | 78ef71a68412dfd47163cb09c5db7603d24c7963b210bb68a50ed07f76294c11 |