Tests¶
The pyrat/tests subdirectory contains Python unit tests. These are translations from the original Rat C++ tests defined across the Project-Rat repositories.
Unit tests act as a safeguard to ensure consistent behaviour between Rat C++ and pyRat Python module. They can also serve as examples to use pyRat.
Structure¶
Unit tests are split following Project-Rat repositories and their respective tests.
pyrat/tests is structured as a Python module
on its own to be used in conjonction with the
Python unittest module.
In that regard all inner __init__.py files
include the same following code for ease of access.
# Allow for unittest discovery
def load_tests(loader, tests, pattern):
return loader.discover(__name__)
This enables more control over which tests to run from the command line.
Run tests¶
Unit tests can be run in different manners from the root of the pyRat repository.
Run all tests:
python -m unittest
Run all tests in verbose mode with Rat logger:
python -m unittest -v
The -v flag enable loggers in test scripts to log information.
Run specific tests:
python -m unittest tests.rat.cmn # Run tests for pyrat.rat.cmn module
python -m unittest tests.rat.fmm.test_soleno # Run the Soleno test for pyrat.rat.fmm module
python -m unittest tests.rat.mdl -v # Run tests for pyrat.rat.mdl module, verbose
Note
Some tests are more beefy than others to run.