Unittest, assertEqual, setUp & tearDown Explained - Python Unit Testing Tutorial #28

2views
00
12:24
T
Taught by Celeste AI - AI Coding Coach
View on YouTube
Description
Learn unit testing in Python! ๐Ÿงช In this lesson, you will learn: โœ… Why automated testing beats manual testing โœ… unittest.TestCase to organize tests into classes โœ… assertEqual to verify return values โœ… assertRaises to test error handling โœ… assertIn to check membership โœ… setUp to create fresh test fixtures before each test โœ… tearDown to clean up after each test โœ… python3 -m unittest -v for verbose test output โœ… Testing classes with state and validation โœ… Mini Project: Gradebook with complete test coverage ๐Ÿ• Timestamps: 0:00 - Introduction 0:22 - Test Basics Explained 0:49 - Test Basics Demo 3:17 - setUp & tearDown Explained 3:44 - setUp & tearDown Demo 6:42 - Gradebook Explained 7:09 - Gradebook Demo 10:53 - Recap 11:28 - End ๐Ÿ’ป Source Code: https://github.com/GoCelesteAI/python_unit_testing ๐Ÿ“š Code from this lesson: # Create a test class class TestMathTools(unittest.TestCase): def test_add(self): self.assertEqual(add(2, 3), 5) def test_divide_by_zero(self): with self.assertRaises(ValueError): divide(10, 0) # Run tests with verbose output python3 -m unittest test_math_tools -v ๐Ÿ”— Previous: Lesson 27 - Virtual Environments ๐Ÿ”— Next: Lesson 29 - File I/O #Python #PythonTutorial #LearnPython #Programming #UnitTesting #unittest #Testing #PythonBasics Tags: Python, Python tutorial, Python for beginners, learn Python, unit testing, unittest, assertEqual, assertRaises, setUp, tearDown, TestCase, testing, TDD, Python basics, CelesteAI Category: Education

Tags

PythonPython tutorialPython for beginnerslearn Pythonunit testingunittestassertEqualassertRaisessetUptearDownTestCasetestingTDDPython basicsCelesteAI
Back to tutorials

Duration

12:24

Published

February 10, 2026

Added to Codegiz

March 15, 2026

Open in YouTube