# capsys

*noun*

say it: **“KAP-sis”** **/ˈkæpsɪs/**

A ready-made pytest fixture that catches what a program prints during a test, so the test can check the text.

## What is **capsys** in pytest?

**capsys** is a fixture pytest has built in that catches what code prints during a test. `capsys.readouterr().out`
gives the printed text, so the test can check it.

```python
def test_receipt_shows_total(capsys):
    print_receipt(12.5)
    assert capsys.readouterr().out == "Total: $12.50\n"
```

## In a sentence

- “The test uses **capsys** to check that the receipt prints its total.”
- “**capsys** caught the welcome message so the assert could read it.”

Level: Journeyman · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=3)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/capsys
