Replies: 1 comment
-
Do you mean something like this? @pytest.fixture
def user_factory() -> Generator[Callable[[], User]]:
with contextlib.ExitStack() as stack:
def create_user():
u = User()
stack.callback(u.delete)
return u
yield create_user |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is a fixture closure?
https://github.com/pytest-dev/pytest/blob/main/src/_pytest/fixtures.py
Beta Was this translation helpful? Give feedback.
All reactions