It helps to use fixtures in pytest.mark.parametrize
Project Links
Meta
Author: Marsel Zaripov
Maintainer: Marsel Zaripov
Classifiers
Development Status
- 4 - Beta
Framework
- Pytest
Intended Audience
- Developers
Topic
- Software Development :: Testing
Programming Language
- Python
- Python :: 2
- Python :: 2.7
- Python :: 3
- Python :: 3.4
- Python :: 3.5
- Python :: 3.6
- Python :: 3.7
- Python :: Implementation :: CPython
- Python :: Implementation :: PyPy
Operating System
- OS Independent
License
- OSI Approved :: MIT License
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.
Feb 01, 2020
0.6.3
Nov 20, 2019
0.6.2
Oct 14, 2019
0.6.1
Oct 13, 2019
0.6.0
Mar 16, 2019
0.5.2
Jan 10, 2019
0.5.1
Jan 05, 2019
0.5.0
Sep 29, 2018
0.4.2
Jul 12, 2018
0.4.1
Nov 30, 2017
0.4.0
Feb 04, 2017
0.3.0
Nov 24, 2016
0.2.0
Wheel compatibility matrix
Files in release
Extras:
None
Dependencies:
(>=3.2.5)
pytest