Testing Python

The py.test module is the simplest of the python unit test tools. You just create methods that start with test_ and contain an assert.

# tests/test_multiply.py
import mymath

def test_multiply():
    assert mymath.multiply(2, 4) == 8

You run tests with py.test tests/test_multiply.py. It can also run all the tests in a specified folder with py.test tests. When running against a folder it will find all files matching test_*.py and run them.