tests package¶
Subpackages¶
Submodules¶
tests.conftest module¶
-
tests.conftest.
abcsmc
(data_api)¶
-
tests.conftest.
base_data_dir
()¶
-
tests.conftest.
data_api
(base_data_dir)¶
-
tests.conftest.
data_api_stochastic
(base_data_dir)¶
-
tests.conftest.
locations
()¶
-
tests.conftest.
short_simulation_dates
()¶
-
tests.conftest.
teardown_remove_data
()¶ Remove test output created during testing.
Datasets defined in data_pipeline_inputs/config.yaml can’t be handled with pytest’s tmp_path, so are cleaned up here. Change these locations as necessary when the config file changes.
tests.utils module¶
-
tests.utils.
calculateInfectiousOverTime
(ts, infectiousStates)¶ Create a list of the number of infectious people over time
- Parameters
ts – pandas dataframe with the entire outbreak timeseries
infectiousStates – compartments considered infectious
-
tests.utils.
compare_mpl_plots
(fig, force_update=False)¶ This function is specialised in comparing matplotlib figures with a baseline. The baseline will be an image inside mpl_images in the current directory, with name matching the test’s name.
The baseline will be automatically created if it doesn’t exist (but the test will still fail). Using force_update allows the user to iterate over how the image looks through running the tests multiple times with the flag enabled.
- Parameters
fig – The produced image you want to check for regressions
force_update – This can be handy during development. Setting this to True will always fail the test, but the baseline image will be updated, so you can easily iterate over the way you want the plotting function called
-
tests.utils.
create_baseline
(test_data, force_update=False)¶ This function is a generic way to keep a baseline fixture updated. It’s specially useful for regression tests. It checks if the baseline_name exists in the desired path, if it doesn’t the test will fail, but this function will write it (so next run will succeed).
This function doesn’t make any assumptions regarding the data inside the files, so it just returns the baseline so that the test can load it and compare.
- Parameters
test_data – the file produced by the test
force_update – set it to true if you want to always overwrite the baseline file (the test will always fail)