pytest-dev / pytest-mimesis

Mimesis integration with the pytest test runner. This plugin provider useful fixtures based on providers from Mimesis.
https://pypi.org/project/pytest-mimesis/
MIT License
62 stars 4 forks source link

Support fixture parametrization #8

Open sobolevn opened 6 years ago

sobolevn commented 6 years ago

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

lk-geimfari commented 6 years ago

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

sobolevn commented 6 years ago

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

lk-geimfari commented 6 years ago

@sobolevn I can try to do it this weekend.

sobolevn commented 6 years ago

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

Soon to be open-sourced.