The ``tests/`` directory '''''''''''''''''''''''' Ideally, every Python code, extension module, or subpackage in Scipy package directory should have the corresponding ``test_.py`` file in ``tests/`` directory. This file should define classes derived from the ``numpy.testing.TestCase`` class (or from ``unittest.TestCase``) and have names starting with ``test``. The methods of these classes whose names contain ``test`` or start with ``bench`` are automatically picked up by the test machinery. A minimal example of a ``test_yyy.py`` file that implements tests for a NumPy package module ``numpy.xxx.yyy`` containing a function ``zzz()``, is shown below:: import sys from numpy.testing import * # import xxx symbols from numpy.xxx.yyy import zzz class test_zzz(TestCase): def test_simple(self, level=1): assert zzz()=='Hello from zzz' #... if __name__ == "__main__": run_module_tests(file) Note that all classes that are inherited from ``TestCase`` class, are automatically picked up by the test runner. ``numpy.testing`` module provides also the following convenience functions:: assert_equal(actual,desired,err_msg='',verbose=1) assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1) assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1) assert_array_equal(x,y,err_msg='') assert_array_almost_equal(x,y,decimal=6,err_msg='') rand(*shape) # returns random array with a given shape To run all test scripts of the module ``xxx``, execute in Python: >>> import numpy >>> numpy.xxx.test() To run only tests for ``xxx.yyy`` module, execute: >>> NumpyTest('xxx.yyy').test(level=1,verbosity=1)