Skip to content

Instantly share code, notes, and snippets.

@ftobia
Created July 26, 2017 19:28
Show Gist options
  • Save ftobia/6f25567355074b7b65d6bf9191a426f5 to your computer and use it in GitHub Desktop.
Save ftobia/6f25567355074b7b65d6bf9191a426f5 to your computer and use it in GitHub Desktop.
import pytest
@pytest.fixture
def foo():
return 'foo value'
@pytest.fixture
def bar():
return 'bar value'
@pytest.fixture
def baz():
return 'baz value'
@pytest.fixture
def my_fixture(request):
return request.getfixturevalue(request.param)
@pytest.mark.parametrize('my_fixture', [
'foo', 'bar', 'baz',
], indirect=['my_fixture'])
def test_thing(my_fixture):
assert 'failure' == my_fixture
"""
Franks-MacBook-Pro:try ftobia$ pytest test_foo.py
============================= test session starts ==============================
platform darwin -- Python 2.7.10, pytest-3.0.5, py-1.4.32, pluggy-0.4.0
rootdir: /Users/ftobia/boxes/try, inifile:
collected 3 items
test_foo.py FFF
=================================== FAILURES ===================================
_______________________________ test_thing[foo] ________________________________
my_fixture = 'foo value'
@pytest.mark.parametrize('my_fixture', [
'foo', 'bar', 'baz',
], indirect=['my_fixture'])
def test_thing(my_fixture):
> assert 'failure' == my_fixture
E assert 'failure' == 'foo value'
E - failure
E + foo value
test_foo.py:27: AssertionError
_______________________________ test_thing[bar] ________________________________
my_fixture = 'bar value'
@pytest.mark.parametrize('my_fixture', [
'foo', 'bar', 'baz',
], indirect=['my_fixture'])
def test_thing(my_fixture):
> assert 'failure' == my_fixture
E assert 'failure' == 'bar value'
E - failure
E + bar value
test_foo.py:27: AssertionError
_______________________________ test_thing[baz] ________________________________
my_fixture = 'baz value'
@pytest.mark.parametrize('my_fixture', [
'foo', 'bar', 'baz',
], indirect=['my_fixture'])
def test_thing(my_fixture):
> assert 'failure' == my_fixture
E assert 'failure' == 'baz value'
E - failure
E + baz value
test_foo.py:27: AssertionError
=========================== 3 failed in 0.04 seconds ===========================
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment