Back to Course
Python Essentials: The Engineering Approach
Module 12 of 20
12. Testing
The Assert Statement
The simplest test. If condition is False, it crashes the app.
pythonassert 2 + 2 == 4, "Math is broken"
Unit Testing
We use the unittest module or pytest framework.
pythonimport unittest def add(a, b): return a + b class TestMath(unittest.TestCase): def test_add(self): self.assertEqual(add(1, 1), 2)