Python unit testing - pytest fixtures

Опубликовано: 07 June 2026
на канале: codebasics
95,687
1k

This tutorial covers a powerful feature in pytest framework called fixtures. It leverages the dependency injection concept for setup and teardown of your unit tests. It is preferred over traditional xunit style setup/teardown methods. The video explains demonstrating problem, issues with test case in the case of code repetition, creating expensive DB connection in every test case and solving problems with fixtures.

Topics that are covered in this Python Video:
0:00 Overview
0:16 Demonstrating problem
3:25 Issues with test case 1. code repetition 2. creating expensive DB connection in every test case
4:32 Setup and teardown methods
7:05 Solving problem with fixtures
9:24 fixtures leverage a concept Dependency injection

Do you want to learn technology from me? Check https://resources.codebasics.io/ydjSKX for my affordable video courses.

You can find code used in this tutorial here: https://github.com/codebasics/py/tree...

Next Video:
Python unit testing - pytest parameters:    • Python unit testing - pytest parameters  

Website: https://resources.codebasics.io/ydjSKX
Facebook:   / codebasicshub  
Twitter:   / codebasicshub