pytest-dev / pytest-dev/pytest

Investigate replacing addfinalizer with ExitStack

Open
#5,592 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: fixtures type: refactoring
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

addfinalizer can be implemented in terms of adding a callback to a stack

it would be interesting if there was a per usage scope fixture for eexit stacks,

then each fixture could get a very own exit stack in a well expressed manner (and if each fixture had one, it wouldnt be as bad to expose it)

Originally posted by @RonnyPfannschmidt in https://github.com/pytest-dev/pytest/pull/5589#issuecomment-510082398

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading pytest's existing addfinalizer implementation and the ExitStack proposal described in the issue. Identify the fixture lifecycle entry points and tests that cover finalizers, then determine whether a per-usage fixture scope is feasible. Done means an agreed design and corresponding implementation and tests, but the issue does not name specific files or test paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.