Skip to content

It helps to use fixtures in pytest.mark.parametrize

License

Notifications You must be signed in to change notification settings

jonasundderwolf/pytest-lazy-fixture

 
 

Repository files navigation

pytest-lazy-fixture travis-ci appveyor pypi

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.

About

It helps to use fixtures in pytest.mark.parametrize

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%