Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-lazy-fixture-0.4.1.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file pytest-lazy-fixture-0.4.1.tar.gz.

File metadata

File hashes

Hashes for pytest-lazy-fixture-0.4.1.tar.gz
Algorithm Hash digest
SHA256 d4986eefe3fb0fb5ab4d572c03b3dd5d01d06bccd8454de641d231aed4268453
MD5 3a9bb93c55d3ca84715b7536dd58622c
BLAKE2b-256 c75a6b5a324b3c80a93178e8c6e1fd059f55182d26d12a3901f4766d30a1dab9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page