TensorLearn
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.

python
assert 2 + 2 == 4, "Math is broken"

Unit Testing

We use the unittest module or pytest framework.

python
import unittest def add(a, b): return a + b class TestMath(unittest.TestCase): def test_add(self): self.assertEqual(add(1, 1), 2)

Mark as Completed

TensorLearn - AI Engineering for Professionals