pytest-dev / pytest-dev/pytest
Difference in call sequence for teardown between fixture class decoration and through usefixtrue field of ini file.
Open
Nobody has claimed this yet.
topic: fixtures
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
As suggested in the discussion 8402 i create the following issue.
As a summary :
- There is a difference in the call order regarding teardown when:
- Your test class is decorated with a fixture using the pytest marker
usefixtures - In the ini file when using the field
usefixturesto specify the same fixture
- Your test class is decorated with a fixture using the pytest marker
What is seen:
- In the case of the fixture decorated class, the fixture teardown is called at the begining of the
teardown_methodof the test class (which is the expected behavior) - In the case of the ini file, the fixture teardown seems to be called at the end of the
teardown_methodof the test class.
Behavior seen with :
- python2.7 && pytest 4.6.11
- python3.8 && pytest 6.2.2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with discussion 8402 and reproduce the teardown-order difference described for class-level and ini-file usefixtures configuration using the reported Python and pytest versions. Trace the fixture setup and teardown paths involved; done means both configurations produce the expected, consistent ordering around teardown_method.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100