Home-made fixture with yield
examples/fixture_inject_around/conftest.py
import pytest @pytest.fixture() def configuration(): print("Before") yield { 'name' : 'Foo Bar' } print("After")
examples/fixture_inject_around/test_app.py
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