Week 14 • Thursday

Block 137: Testing with pytest

Write and run automated tests for your Python functions.

Concepts

Code Examples

See exercise below.

Exercise

Write 5 tests for your compute_bmi() function (normal cases, edge cases, invalid input). Create a conftest.py fixture that provides a sample DataFrame for multiple tests.

Homework

Why should you write tests BEFORE you think your code is working? What is TDD?