Start here. This is the direct spoken answer to practice first.
Overview
Explains reverse-order fixture cleanup and designs teardown that remains safe when setup or tests fail.
A yield fixture performs setup before yield, gives the yielded value to the test, and runs the code after yield during teardown. Pytest unwinds successfully created fixtures in reverse dependency order, even when the test fails. I keep each fixture responsible for one resource so its cleanup is clear. Teardown should target only resources that fixture actually created.