Running tests

In TARDIS, we focus primarily on unit tests. These tests check the outputs of individual functions, ensuring that each component behaves as expected.

Unit tests run quickly and are executed after every suggested change to TARDIS, allowing for immediate feedback and maintaining code quality.

All of them are based on the excellent astropy-setup-helpers package and pytest.

Running the Unit Tests

This is very straightforward to run on your own machine. For very simple unit tests, you can run this with:

> pytest tardis

Running the more advanced unit tests requires TARDIS Regression data that can be downloaded (tardis-regression-data). Git LFS is used to download the large regression data files in the tardis-regression-data repository.

> git lfs pull

The tardis-regression-data repository should be located outside of the main tardis repository, rather than being nested within it.

Warning

We have migrated from tardis-refdata to``tardis-regression-data``.

Finally, the tests can be run using the following command

> pytest tardis --tardis-regression-data=/path/to/tardis-regression-data/

Or, to run tests for a particular file or directory

> pytest tardis/path/to/test_file_or_directory --tardis-regression-data=/path/to/tardis-regression-data/

Warning

In some cases you might have to update the regression data. The steps to update the regression data are outlined in the Update the Regression Data.

Warning

The tests workflow runs on pull requests and on push events. To prevent leaking LFS quota, tests have been disabled on forks. If, by any chance, you need to run tests on your fork, make sure to run the tests workflow on master branch first. The LFS cache generated in the master branch should be available in all child branches. You can check if cache was generated by looking in the Restore LFS Cache step of the workflow run. Cache can also be found under the “Management” Section under “Actions” tab.

Generating Plasma Reference

You can generate Plasma Reference by the following command:

> pytest -rs tardis/plasma/tests/test_complete_plasmas.py
--tardis-regression-data="/path/to/tardis-regression-data/" --generate-reference