Running Tests
Carsus’s tests are based on the AstroPy Package Template and pytest. Then, running simple tests on your machine is straightforward:
$ pytest carsus
Optional Flags
A set of flags can be appended to the above command to run different kinds of tests:
--remote-dataRun tests marked with the
@pytest.mark.remote_datadecorator. Requires an internet connection.
--test-db=/path/to/carsus-db/test_databases/test.dbRun test for the Carsus SQL output module. Requires data from the tardis-sn/carsus-db repository.
--refdata=/path/to/carsus-refdataRun tests marked with the
@with_refdatadecorator. Requires the tardis-sn/carsus-refdata repository.
--cov=carsus --cov-report=xml --cov-report=htmlGet code coverage results using the pytest-cov plugin.
--arraydiff-generate-path=carsus-refdata/arraydiffGenerate reference files for tests marked with
@pytest.mark.array_comparedecorator and save them in the refdata folder.
--arraydiff --arraydiff-reference-path=carsus-refdata/arraydiffRun tests marked with
@pytest.mark.array_comparedecorator. The tests would look for reference files in the refdata folder which can be generated using the above option.
Notebook Tests
These are pseudo-integration tests that require the CARSUS_REFDATA environment variable exported before run:
jupyter nbconvert --execute --ExecutePreprocessor.timeout=600 --to html carsus/io/tests/test_legacy_consistency.ipynbjupyter nbconvert --execute --ExecutePreprocessor.timeout=600 --to html carsus/io/tests/test_output_base.ipynb