You want to use `pytest.fixture` for that.