Skip to content

Useful Testing Tricks

DanRyanIrish edited this page Dec 17, 2020 · 2 revisions

Regenerate Figure Hash Library

Regenerating the hash library involves running the figure tests, taking the figures produced, and rewriting the hashes. This is required if a the output of a plot test has changed and the user is sure the new version is the correct one. It is also required if a new plotting test is written as a new hash is needed to compare the output of the new test.

To regenerate the hash library, do:

$ tox -e <tox-figure-env> -- --mpl-generate-hash-library=<figure-hash-json-file>

e.g.

$ tox -e py38-figure -- --mpl-generate-hash-library=ndcube/tests/figure_hashes_mpl_332_ft_261_astropy_41_sunpy_203.json

Different test environments may rely on different hash libraries as older versions of packages may produce slightly different figures. To find the correct file .json file used by the relevant tox-figure-env test environment, run the tox-figure-env tests, e.g. $ tox -e py37-figure-devdeps. When the tests fail it should print out the related .json file. Then rebuild the hash library as shown above with the relevant file, and rerun the tests. They should now pass thanks to the updated hash library.

Clone this wiki locally