`request.addfinalizer` order of execution is undocumented
See original GitHub issueThis is very important if you are creating fixtures which interact with others which were not written with yield, and is extra confusing when writing tests which themselves do use yield.
Issue Analytics
- State:
- Created a year ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Pytest Finalizers - order of execution - Stack Overflow
I guess the easiest way would be to just try running your code with -s and see in which order the prints happen....
Read more >pytest-django - Read the Docs
function requesting your fixture has this marker applied, depending on pytest's fixture execution order. To access.
Read more >1.9.0 (2020-06-24) — py 1.9.1.dev3+g2da2cae documentation
fix issue35 - define __gt__ ordering between a local path and strings ... from request.addfinalizer() because request.cached_setup has the scope arg.
Read more >All You Need To Know To Start Using Fixtures In Your Pytest ...
To define a teardown use the def fin(): ... + request.addfinalizer(fin) construct to do the required cleanup after each test. You can also...
Read more >Changelog — pytest documentation
#9708: pytester now requests a monkeypatch fixture instead of creating one internally. ... #5196: Tests are now ordered by definition order in more...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yeah, sounds great, thanks. I think just a paragraph stating that they are executed in first-in-last-out order is enough. 👍
Hey eveyrone! I haven’t seen progress on this issue for some time, so I took the liberty to try and address it on https://github.com/pytest-dev/pytest/pull/10171.
I’d love to hear your thoughts on it 🙏