For Developers

Testing Infrastructure

Muscat comes with two ways of executing the automated tests. Remember that if not all the optional dependencies are installed some tests will fail. First, pytest [2] by simply executing in root directory of the library:


The files and pytest.ini present at the root of the repository are responsible for the pytest configuration.

And the in-house testing tool using.

python -m Muscat.Helpers.Tests

This module searches all the modules recursively (in Muscat) and collectes all the functions named CheckIntegrity that take one boolean argument (True to generate output in the form of GUI to ease the manual debugging). The CheckIntegrity function returns the string "ok" if and only if the test was successful (or "skip" to ignore the test). Any other return value (or a raised exception) will be interpreted as a failed test.


This tool can be used to test an installed version of Muscat to check the integrity of the installation on the final user environment.

The must have a variable named _test listing all submodules to be tested so that the test infrastructure works as intended.

Some tests need to write data to disk or read data from the test data directory. Two functions are available to help writing tests :

  • GetTestDataPath() : Returns the path of the test data directory (from Muscat.TestData import GetTestDataPath )

  • TemporaryDirectory: A class to handle the creation of a directory to hold temporary data (from Muscat.Helpers.IO.TemporaryDirectory import TemporaryDirectory)

For more information about the options, use the command :

python -m Muscat.Helpers.Tests -h


Some test will fail on some configuration Some packages are not available on all the supported platforms and some classes must be used inside a specific environments (paraview for example) The current know issues are :


Coverage is an important part of the development process. To activate the coverage during test use the -c option.

If you want to tell to ignore some part of the code, use the #pragma : no cover comment. For correct platform dependent coverage you can use the following comment to disconnect coverage in some platform:

# only nt coverage
# only posix coverage

See also [3].

Disabling Tests

Some tests can be disabled using an environment variable. A typical use case arises when a test relies on an external dependency that may not be available.

The feature relies on the definition of non-empty environment variables in the form : "XXXXX_NO_FAIL".

An example is available in the Muscat.Bridges.PyVistaBridge.CheckIntegrity() function.

Experimental CMake Compilation

Cmake compilation is currently experimental, only compilation and testing are supported (no installation for the moment). The CMakeList.txt file present at the root of the project contains the entry point for the compilation. Compilation (using ninja) in “release” can be done using the folowing commands: For more information about option of cmake please refer to the cmake documentaion [5]:

mkdir cmake_build
cd cmake_build
cmake -G Ninja -DPython_FIND_STRATEGY=LOCATION -DCMAKE_BUILD_TYPE=Release --fresh ..

To build the project:

cmake --build .

To install (this is experimental not supported for all OS/python version/distributions)

cmake --install .

To run all the tests