Module 13: Python Testing and Debugging

Advanced 9 chapters

167. Debugging Fundamentals

Learn a calm, step by step way to find and fix bugs: read error messages, reproduce the problem, use print and logging, and test your guesses.

Intermediate30 min

168. Python Debugger

Learn to use pdb, the built-in Python debugger: stop a program at a chosen line, step through code, look at variables and find bugs without filling the code with prints.

Intermediate30 min

169. Logging

Learn how to use the logging module to record what your program does, with levels, formats, handlers and named loggers, instead of scattering print calls.

Intermediate30 min

170. Unit Testing

Understand what unit tests are, why they matter, and how to write small automatic checks with assert for functions, including edge cases and the arrange-act-assert pattern.

Intermediate30 min

171. unittest Module

Write organised tests with the built-in unittest module: TestCase classes, assert methods, setUp and tearDown, testing exceptions, and running tests from the command line.

Intermediate35 min

172. pytest Fundamentals

Get started with pytest: plain test functions, simple asserts with detailed failure reports, fixtures, parametrized tests, pytest.raises and running tests from the command line.

Intermediate35 min

173. Assertions

Learn how the assert statement checks your assumptions while a program runs, how to write helpful failure messages, and when assertions are the wrong tool.

Intermediate25 min

174. Test Cases

Learn what a test case is, how to write one with the unittest module, how to cover normal, edge and error situations, and how to read the results.

Intermediate30 min

175. Code Quality and Best Practices

Learn the habits that make Python code clean and easy to maintain: PEP 8 style, good names, docstrings, small functions, type hints, and avoiding common traps.

Intermediate30 min

Take the module test