Pytest is already one of the best testing frameworks in Python—but its default output is plain, and sometimes difficult to parse when you’re running a large test suite.
If you've ever squinted at a wall of plain-text failures, or wished your test results had more color, structure, or interactivity… you're in the right place.
In this guide, we’ll explore:
- Why pytest output looks the way it does
- How to enhance pytest output using community plugins
- Side-by-side examples of different output styles
- Plugins for beginners, intermediate users, and advanced setups
- Command-line usage, setup instructions, and configuration tips
Whether you're a Django, FastAPI, data, or backend developer—this guide will dramatically improve your testing experience.
1. Why Pytest Output Is Boring by Default
Default pytest output:
collected 12 items
test_example.py .......F....
================================ FAILURES ================================
_______________________________ test_function ____________________________
AssertionError: assert 2 == 5
It works—but:
- No color variation
- Failures disappear in a sea of
.F... - Hard to read when running dozens or hundreds of tests.
- CI logs become painful to inspect.
So let's fix that.
2. Making Pytest Beautiful (Essential Plugins)
Here are the most impactful pytest plugins for improving output:
| Plugin | Purpose |
|---|---|
| pytest-sugar | Prettier progress bar, colorful output |
| pytest-rich | Rich-powered console formatting |
| pytest-clarity | Improves assertion diffs |
| pytest-cov | Coverage report with colors and percentages |
| pytest-instafail | Show failures immediately as they happen |
| pytest-md | Markdown output for CI |
| pytest-tldr | Very short summary mode |
| rich | Adds color + formatting engine |
Let’s go step-by-step.
3. Pytest Sugar — Prettier Test Progress
Best for: beginners, immediate improvement
Install:
pip install pytest-sugar
Sample Output:
──────────────────────────────────────────────────────────────────────────── pytest session starts ────────────────────────────────────────────────────────────────────────────
platform linux -- Python 3.10, pytest-9.0.2
rootdir: /home/project
❱ megaproject/tests/crm/test_example.py ✓ ✓ ✓ ✓
4 passed in 0.14s
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
This adds:
- A progress bar
- Unicode glyphs
- Colored passes/fails
- Cleaner failure messages
Enable automatically:
pytest.ini
[pytest]
addopts = -s --disable-warnings
pytest-sugar loads automatically when installed.
4. Pytest Rich — Rich Console Output (Beautiful Colors + Layout)
Best for: developers who want maximum readability
Install:
pip install pytest-rich
Run:
pytest --rich
Before Rich
FAILED tests/test_api.py::test_get_user - AssertionError: 404 != 200
After Rich
────────────────────────────── FAILED tests/test_api.py::test_get_user ──────────────────────────────
❌ AssertionError: Expected HTTP 200, got 404
Path: /api/v1/user/
Payload: {"id": 1}
────────────────────────────────────────────────────────────────────────────────────────────────────
Rich adds:
- Colored panels
- Better tracebacks
- Better diffs
- Looks great in CI (GitHub Actions)
5. Pytest Clarity — Better Assertion Diff
Install:
pip install pytest-clarity
Run normally:
pytest
Example Failure (default)
E AssertionError: assert {'a': 1, 'b': 2} == {'a': 1, 'b': 3}
Example with Clarity enabled
Comparing dicts:
b:
- 2
+ 3
Much more readable!
6. Pytest Coverage — Highlight untested code
Install:
pip install pytest-cov
Run with coverage:
pytest --cov=myapp --cov-report=term-missing
Output:
----------- coverage: platform linux, python 3.10 -----------
Name Stmts Miss Cover Missing
----------------------------------------------------------
myapp/models.py 120 10 92% 144-152
myapp/views.py 80 25 69% 35-60
----------------------------------------------------------
TOTAL 200 35 83%
You get:
- Color-coded coverage
- List of missing lines
- Summary percent
Works beautifully with Django.
7. Pytest Instafail — Show Failures Immediately
Ideal for long test suites.
pip install pytest-instafail
Run:
pytest --instafail
Now failures appear AS SOON AS THEY HAPPEN, not after all tests complete.
8. Pytest Summary Plugins
pytest-tldr
Gives a super-short summary of test results.
pip install pytest-tldr
Add to config:
[pytest]
addopts = --tldr
Output:
✨ 324 passed | 3 failed | 12 skipped
Perfect for CI dashboards.
9. Combining Plugins for the Best Output
Here’s a recommended combination:
pytest-sugar
pytest-rich
pytest-clarity
pytest-cov
pytest-instafail
pytest-tldr
Add to pytest.ini:
[pytest]
addopts = --rich --tldr --cov=myapp --cov-report=term-missing
Sample final output:
🔥 Running tests with style…
───────────────────────── 12 passed, 1 failed, 2 skipped in 2.31s ─────────────────────────
----------- coverage: platform linux, python 3.10 -----------
Name Stmts Miss Cover Missing
-----------------------------------------------------------
myapp/models.py 120 10 92% 144-152
-----------------------------------------------------------
✨ Done! 92% coverage.
10. Extra Tools for CI/CD Formatting
pytest-md (Markdown Output for CI)
pip install pytest-md
pytest --md=report.md
CI can attach the HTML/Markdown output.
pytest-html
pip install pytest-html
pytest --html=report.html --self-contained-html
Produces a professional HTML report with:
- screenshots
- logs
- attachments
Great for Selenium, API tests, Django admin UI tests.
11. What Should Beginners Choose?
| Level | Recommended Plugins |
|---|---|
| Beginner | pytest-sugar, pytest-clarity |
| Intermediate | pytest-rich, pytest-cov |
| Advanced | pytest-html, pytest-md, pytest-instafail |
12. Full Example: requirements-dev.txt for a Beautiful Pytest Setup
pytest==9.0.2
pytest-rich
pytest-sugar
pytest-clarity
pytest-cov
pytest-instafail
pytest-tldr
rich
13. Conclusion
Improving pytest output is one of the easiest ways to:
- Speed up debugging
- Reduce cognitive load
- Improve collaboration with teammates
- Produce better CI logs
- Make your test suite more enjoyable
Pytest is powerful—but when paired with the right plugins, it becomes truly developer-friendly.
Top comments (0)