Learn pytest with free notebooks
20 free video lessons that use pytest, each with a downloadable Jupyter notebook and, where needed, the dataset. Learn pytest by working through real examples.
About these pytest lessons
pytest is the most widely used testing framework for Python. These lessons go from your first test to testing a real package: fixtures and their scopes, conftest.py, parametrize, mocking and monkeypatch, markers, assertions, temporary files, capturing output and logs, testing exceptions and warnings, coverage with pytest-cov, parallel runs with pytest-xdist, plugins, and running your tests in CI.
These 20 lessons come from 3 different courses, so you see pytest used in several settings. The course with the most pytest lessons is Pytest deep dive (18 lessons).
pytest is most often used here together with logging, JSON, pathlib and subprocess.
Watch the video, then run the notebook yourself: changing the code and re-running it is the fastest way to learn.
Courses that use pytest
- Pytest deep dive – 18 lessons
- Python Beginner Course – 1 lesson
- FastAPI deep dive – 1 lesson
59 minPython Debugging for Beginners: Read Errors, Fix Bugs, Write Tests (Beginner Python Course, Part 5)

FastAPI Tutorial #17: Testing FastAPI Apps with pytest

pytest Tutorial #1: Getting Started — Your First Python Test

pytest Tutorial #2: Fixtures Basics

pytest Tutorial #3: Parametrize — Many Cases, One Test

pytest Tutorial #4: Mocking & Monkeypatch

pytest Tutorial #5: Markers — Organising and Selecting Tests

pytest Tutorial #6: Assertions Deep Dive

pytest Tutorial #7: conftest.py & Sharing Fixtures

pytest Tutorial #8: Fixture Scopes & Finalisation

pytest Tutorial #9: Test Organisation That Scales

pytest Tutorial #10: Parametrised & Indirect Fixtures

pytest Tutorial #11: Plugins — Extending pytest

pytest Tutorial #12: Coverage with pytest-cov

pytest Tutorial #13: Temporary Files & Directories

pytest Tutorial #14: Capturing Output & Logs

pytest Tutorial #15: Parallel Testing with pytest-xdist

pytest Tutorial #16: Testing Exceptions & Warnings

pytest Tutorial #17: CI Integration & Configuration

pytest Tutorial #18: Capstone — Testing a Real Package End to End
Frequently asked questions
Where should I start learning pytest?
Start with “Python Debugging for Beginners: Read Errors, Fix Bugs, Write Tests (Beginner Python Course, Part 5)”, then work through the Pytest deep dive course.
Are these pytest lessons free?
Yes. Every video, notebook and dataset on this site is free to use for learning.
Can I run the pytest notebooks without installing Python?
Yes. Open them in Google Colab, or use the Run in browser button where a lesson has one.