Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Home-made fixture with yield

import pytest

@pytest.fixture()
def configuration():
    print("Before")

    yield { 'name' : 'Foo Bar' }

    print("After")
def test_app(configuration):
    print("In test")
    print(configuration)
    assert True

$ pytest -sq
Before
In test
{'name': 'Foo Bar'}
.After

1 passed in 0.02 seconds