pytest-mimesis icon indicating copy to clipboard operation
pytest-mimesis copied to clipboard

Support fixture parametrization

Open sobolevn opened this issue 7 years ago • 4 comments

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

sobolevn avatar Jul 10 '18 09:07 sobolevn

Looks useful. I'm all for it :+1:.

lk-geimfari avatar Jul 10 '18 10:07 lk-geimfari

@lk-geimfari do you have free time to help me with this one?

sobolevn avatar Jul 10 '18 10:07 sobolevn

@sobolevn I can try to do it this weekend.

lk-geimfari avatar Jul 10 '18 10:07 lk-geimfari

@lk-geimfari counting on you! I am using this library in production.

Soon to be open-sourced.

sobolevn avatar Jul 10 '18 13:07 sobolevn