Skip to content

Developer Environment / pytest

Python has built-in unit test features:

However, the pytest software is a useful tool that provides enhanced unit test features, which can can also be used for functional testing of Python and other software.

See the pytest documentation.

See also a comparison of Python testing frameworks.

Install pytest

To install pytest for the installed Python 2 environment and assuming pip is installed, run the following on Windows, Cygwin, or Linux:

$ pip install -U pytest
Collecting pytest
  Downloading pytest-3.0.3-py2.py3-none-any.whl (169kB)
    100% | 172kB 1.7MB/s
Collecting py>=1.4.29 (from pytest)
  Downloading py-1.4.31-py2.py3-none-any.whl (81kB)
    100% | 86kB 2.3MB/s
Installing collected packages: py, pytest
Successfully installed py-1.4.31 pytest-3.0.3

Additional pytest Configuration

The following may be useful: improve slow startup.

Writing pytest Tests

See the testing task documentation for examples of tests.