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
File details
Details for the file pytest-lazy-fixture-0.6.3.tar.gz
.
File metadata
- Download URL: pytest-lazy-fixture-0.6.3.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191212 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e7d0c7f74ba33e6e80905e9bfd81f9d15ef9a790de97993e34213deb5ad10ac |
|
MD5 | d58a9fbd0ccee6903d8e2cce2b4c9e19 |
|
BLAKE2b-256 | b282ae6d2f6903719c4ec410dcd31ee24e3bce74b2cef3c5b9150ad36e8594b6 |
File details
Details for the file pytest_lazy_fixture-0.6.3-py3-none-any.whl
.
File metadata
- Download URL: pytest_lazy_fixture-0.6.3-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191212 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0b379f38299ff27a653f03eaa69b08a6fd4484e46fd1c9907d984b9f9daeda6 |
|
MD5 | d4cc73680f20630f471965e4cc40694a |
|
BLAKE2b-256 | 2da12f2c1c2353350d66c4d110d283e422e4943eb5ad10effa9357ba66f7b5b9 |