Unit tests

The spacepy_testing module

The spacepy_testing module contains utilities for assistance with testing SpacePy. It is not installed as part of SpacePy and is thus only importable from the unit test scripts themselves (which are in the same directory). All unit test scripts import this module, and should do so before importing any spacepy modules to ensure pathing is correct.

On import, add_build_to_path() is run so that the build directory is added to the Python search path. This means the tests run against the latest build, not the installed version. Remove the build directory to run against the installed version instead. The build directory does not completely separate out Python versions, so removing the build directory (and rebuilding) is recommended when switching Python versions.

Build the package before running the tests:

python setup.py build


assertWarns(test[, action, message, ...])

Tests that a warning is raised.

assertDoesntWarn(test[, action, message, ...])

Tests that a warning is not raised.



Adds the python build directory to the search path.



Directory containing unit test data


Directory containing the unit test scripts



Doc generation date

Apr 27, 2022