Git repository for the talk:


The presentation

In this talk, I will cover:

The pieces

Test modules

`nosetests` command line program

Test functions and classes


>>> assert_set_equal(set([1, 2, 3]), set([1, 2, 4]) )

AssertionError: Items in the first set but not the second:
Items in the second set but not the first:

Look at how it prints exactly what the difference is. Maybe you don't even need to go debugging it yourself if this is enough to realize what went wrong.

What assertions are available?

See the list of assert* methods

Invoking the python debugger

If a test fails, you can automatically invoke the debugger:

Useful pdb commands:

Full list of commands:

The ipython debugger is functionally equivalent to pdb.

If you want to invoke the debugger at one specific point, just use the raise keyword at that point:


if n == 5:

Learning by example

Recommendations for making tests

How to debug a failing test

Full example: Permutations

Prime number testing

Fibonacci numbers


Test-driven development


Euler 001: sum of multiples of 3 and 5


If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.


Further topics

Statistical tests

SoftwareTesting2 (last edited 2014-06-05 11:30:40 by RichardDarst)