Skip to content
프로젝트

TvoroG/pytest-lazy-fixture

GitHub에서 보기

소개

It helps to use fixtures in pytest.mark.parametrize

개발 도구

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

pytest-lazy-fixture travis-ci appveyor pypi

Use your fixtures in @pytest.mark.parametrize.

Installation

pip install pytest-lazy-fixture

Usage

pytest-lazy-fixture lets you use a fixture as one of the values passed in @pytest.mark.parametrize:

import pytest
from pytest_lazyfixture import lazy_fixture

@pytest.fixture
def one():
    return 1

@pytest.mark.parametrize('arg1,arg2', [
    ('val1', lazy_fixture('one')),
])
def test_func(arg1, arg2):
    assert arg2 == 1

This can be even more useful when the fixture is itself parametrized:

import pytest
from pytest_lazyfixture import lazy_fixture

@pytest.fixture(params=[1, 2])
def one(request):
    return request.param

@pytest.mark.parametrize('arg1,arg2', [
    ('val1', 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
from pytest_lazyfixture import lazy_fixture

@pytest.fixture(params=[
    lazy_fixture('one'),
    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.

관련 프로젝트 살펴보기

불러오는 중…