Link

Python Testing

At the lowest level, checking that code runs correctly can involve simply adding some assert() statements. There are more structured approaches.

unittest and doctest

A standard part of recent Python versions. Closely based on Java’s JUnit, so somewhat verbose in the Java tradition.

pytest (or py.test)

More concise and pythonic than unittest, this is a separate package that needs to be installed. Very popular.

Links: docs, GitHub

Books:

Blogs:

nose

Sort of an enhanced unittest, it appears to be falling in popularity as pytest becomes the standard.

tox, nox, etc

Intended to automate and standardize testing in Python, these are virtualenv managers that can run test suites across a variety of environments.

Tox: docs

Dox: docs

See also

Testing feeds into continuous integration (CI), which has a separate page.