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. .. code-block:: python # 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: .. code-block:: bash python -m unittest - Run all tests in verbose mode with Rat logger: .. code-block:: bash python -m unittest -v The ``-v`` flag enable loggers in test scripts to log information. - Run specific tests: .. code-block:: bash 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. .. Links .. _Project-Rat: https://gitlab.com/project-rat .. _PRE Docs: https://gitlab.com/project-rat-extras/docs .. _Project-Rat: https://gitlab.com/project-rat .. _Project-Rat-Extras: https://gitlab.com/project-rat-extras .. _pyRat: https://gitlab.com/project-rat-extras/pyrat .. _pyrat/tests: https://gitlab.com/project-rat-extras/pyrat/-/tree/main/pyrat/tests?ref_type=heads .. _Python: https://www.python.org/ .. _Python unittest module: https://docs.python.org/3/library/unittest.html