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.6.2.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_lazy_fixture-0.6.2-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest-lazy-fixture-0.6.2.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for pytest-lazy-fixture-0.6.2.tar.gz
Algorithm Hash digest
SHA256 eb2f4573b371c690b91e637d09dfa30e2d6ba1234833df1920fc8b7b0d0fcebb
MD5 04e6217fc2fa11a07f5dd7a7bde266b4
BLAKE2b-256 8fb5d439041afbd93d822820de2828e95951f00dea48fe5836d93fd055ef67f9

See more details on using hashes here.

File details

Details for the file pytest_lazy_fixture-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: pytest_lazy_fixture-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for pytest_lazy_fixture-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bcdc184ef988abbde2d906330a7f681595c8e9753a5ff07c5a9860389aa3b766
MD5 48a773d1ff5d30b4d0ba4e97ecbeae93
BLAKE2b-256 1d1b0595cd5ac9df5b2121d049b30b33e3bf27a5be8b03025652d798f325fc1f

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