serhii.net

In the middle of the desert you can say anything you want

21 Jun 2022

Pytest fixtures that yield instead of return for better cleanup code

In the documentation, found out that yield is the recommended way to return stuff from fixtures.

Amongs other neat bits, any cleanup code after it will get executed when the fixture itself gets destroyed (based on scope).

pytest fixtures: explicit, modular, scalable — pytest documentation

Nel mezzo del deserto posso dire tutto quello che voglio.