# Fixtures and Temporary Files

A pytest fixture builds the setup several tests share and hands each test a fresh copy, tmp_path gives each test its own empty folder to write files in, and capsys lets a test read what a function printed.

![Cheat sheet: Fixtures and Temporary Files](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/d9303f0cc39147cfaa559b7b2e4e7806.webp)

- Category: Python
- Level: Journeyman
- Tags: capsys, python, Test Fixture (python), Test Isolation, tmp_path
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/python-testing-fixtures-and-tmp-path-cheat-sheet
