Testing
test blocks and the assert family: a program checks its own results and prints which tests passed and which failed. Run a cell to see its output beside the expected one.
A passing test
assert_near(a, b, tol) inside a named test block. What prints is the name — one line per test, however many assertions are inside.
Viv [1]
A failing test says what failed
The FAIL line names the test and shows the failing assertion's values, so you see which check failed and by how much.
Viv [2]
Test a function against a property
Check a function against a mathematical fact it must satisfy (here, the partial sums of 1/k! converge to e), not only against fixed values.
Viv [3]