How To Write Unit Tests in Python • Pytest Tutorial @pixegami
How To Write Unit Tests in Python • Pytest Tutorial  @pixegami
Uploaded April 2022 | Updated September 2026, 3 days ago
Learn how to test your Python code by writing unit tests with the Pytest framework.

In this video I'll be covering how to write and run unit tests, how to check if an Error is raised, how to use test fixtures, and how to mock dependencies.

💻 Code: github.com/pixegami/simple-pytest-tutorial
👉 Pytest Documentation: docs.pytest.org
👉 Unittest Mock: docs.python.org/3/library/unittest.mock.html

📚 Chapters

00:00 Introduction
02:45 Install Pytest and setup the project
04:14 Running your first unit test
06:50 Implement your test (with "assert")
11:24 How to test that an Error is raised
18:30 How to run a specific unit test file/method
19:50 How to see print statements in pytest
20:27 Implementing "get_total_price" test
23:10 Using pytest fixtures to set up context for your tests
27:00 When your tests depends on another module
30:50 How to mock dependencies (using unittest Mock)
34:30 Wrap-up

#pytest #python
How To Write Unit Tests in Python • Pytest TutorialLearn Python • #6 Loops • How to Repeat Code ExecutionBuild a Custom AI RPG Game with OpenAI GPTsHow I Would Learn Python (if I had to start over) • A Roadmap for 2023Learn Python • #8 Tuples and Sets • More Ways To Store Data!Learn Python • #3 Operators • Add, Subtract and More...Build a Simple RAG Pipeline in 30 Minutes!How To Build a CRUD (TO-DO) App on AWS using FastAPI and PythonPython FastAPI Tutorial: Build a REST API in 15 MinutesUV: The Python Tool Everyone Is Switching ToAmazon Bedrock Tutorial: Generative AI on AWSDeploy RAG to Production Faster Than You Think
pixegami |

How To Write Unit Tests in Python • Pytest Tutorial

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER