Last active
September 2, 2016 13:07
-
-
Save maximiliano/669c899f0ff052c88f6649c23c5cf7b9 to your computer and use it in GitHub Desktop.
Parametrized tests
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
@pytest.fixture(params=('a', 'b', 'c')) | |
def simple_params(request): | |
return request.param | |
def test_params1(simple_params): | |
assert True is True | |
# test_params1[a] PASSED | |
# test_params1[b] PASSED | |
# test_params1[c] PASSED | |
@pytest.fixture(params=(('a', 'x', 1), ('b', 'y', 2), ('c', 'z', 3))) | |
def complex_params(request): | |
return request.param | |
def test_params2(complex_params): | |
assert True is True | |
# test_params2[complex_params0] PASSED | |
# test_params2[complex_params1] PASSED | |
# test_params2[complex_params2] PASSED | |
@pytest.mark.parametrize('a', [object()]) | |
def test_foo(request, a): | |
print(request.node.name) | |
def test_params3(request, complex_params): | |
print(request.node.name) | |
# 'test_params3[complex_params0]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment