modelutil: Testing

General

If you make changes and additions to the package, the modelutil package provides a variety of ways to test the package's code. Although development and testing of the package was done on a Debian GNU/Linux system, most of the tests should work on other platforms.

On a minor note, in the Debian release of Python, there is a difference between versions 2.2 and 2.3 as to how the output to stdout from a KeyError exception is formatted: in 2.3, if the key is a string, single quotes are output; in 2.2, no quotes were output. As the docstring unit tests are formatted for Python 2.3, an error will be returned in the docstring test for this case.

Module Unit Testing Using doctest

All (or nearly all) modules make use of the doctest module which executes all example docstrings in the module. For instance, to check that the field module passes its docstring unit tests, in the source code directory at the OS command line just type:

> python field.py

If there are no problems, you should get back nothing.

Module Unit Testing Using unittest

The doctest package is limited in the complexity of tests it can subject a module to. For more complex testing of select modules the unittest package is used. Scripts executing these tests are found in the modelutil/test directory. The README.txt file in that directory gives details.

To execute the test of the field module, using rank-2 arrays, go to the modelutil/test directory and type the following at the OS command line:

> python test_field_rank2.py

If there are no problems, you should get back something like the following:

......
----------------------------------------------------------------------
Ran 6 tests in 0.150s

OK

The top line of periods shows the number of tests run and passed (in the above case, 6). The number of tests will change as new tests are added to the script. If all tests are passed, however, the final line output will be the OK as seen above.

Return to modelutil Reference Manual Index.
Return to modelutil Home Page.

Valid HTML 4.01! Valid CSS! Updated: August 30, 2004 by Johnny Lin <email address>. License.