pytest-dev/pytest-mimesis

Support fixture parametrization

开放

#8 创建于 2018年7月10日

 (4 条评论) (1 个反应) (0 位负责人)Python (4 个派生)github user discovery
hacktoberfesthelp wanted

仓库指标

星标
 (61 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Imagine I have the following fixture:

@pytest.fixture(scope='function')
def gitlab_merge_request(mimesis):
    return {
        'user': {
            'username': mimesis('username'),
        },
        'object_attributes': {
            'id': mimesis('between', minimum=1),
            'state': 'opened'
        },
    }

What I want to achieve is something like:

import pytest

@pytest.mark.parametrize(
    'gitlab_merge_request__object_attributes__state', ['closed'],
)
def test_is_closed(gitlab_merge_request):
    assert gitlab_merge_request['object_attributes']['state'] == 'closed'

We can use https://docs.pytest.org/en/latest/fixture.html#override-a-fixture-with-direct-test-parametrization

贡献者指南