Created
May 15, 2017 06:42
-
-
Save edofic/aeab43fab80d315932b32df0ec862920 to your computer and use it in GitHub Desktop.
Indirect parametrization in pytest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
@pytest.fixture() | |
def user(request): | |
user = 'mock user' | |
if hasattr(request, 'param'): | |
user += ': {}'.format(request.param) | |
return user | |
@pytest.mark.parametrize('user', ('foo',), indirect=True) | |
def test_foo(user): | |
assert user == 'mock user: foo' | |
@pytest.mark.parametrize('user', ('bar',), indirect=True) | |
def test_bar(user): | |
assert user == 'mock user: bar' | |
def test_default(user): | |
assert user == 'mock user' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment