How-To's‎ > ‎Python‎ > ‎

unit tests

Creating a testing framework with standard module unittest and setuptools

To run all tests: python setup.py test

Setup.py allows selective testing of modules or suites
python setup.py test --test-module package.tests.module_test                   # run module_test.py
python setup.py test --test-suite package.tests.module_test.test_suite  # run test_suite within module_test.py

Alternatively, unittest has a command line interface that allows running of modules, suites, and even single cases:
python -m unittest module_test                                                         # run module_test.py
python -m unittest module_test.TestClass                                # run test class TestClass inside module_test.py
python -m unittest module_test.TestClass.test_method # run test case test_method inside test class TestClass inside module_test.py