pytest-dev/pytest-mimesis

Support fixture parametrization

Aperta

#8 aperta il 10 lug 2018

 (4 commenti) (1 reazione) (0 assegnatari)Python (4 fork)github user discovery
hacktoberfesthelp wanted

Metriche repository

Star
 (61 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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

Guida contributor