Case Study: Building Software in Python
Mark Pedigo
Principal Data Scientist
# math.py
def add(a, b):
return a + b
# test_math.py
import pytest
def test_add():
assert add(2, 3) == 5
assert add(-1, 1) == 0
assert add(0, 0) == 0
assert add(-5, -7) == -12
Run in the console:
pytest test_math.py
===== test session starts ===== collected 1 item test_math_functions.py . [100%] ====== 1 passed in 0.03s ======
Case Study: Building Software in Python