dimanche 7 mars 2021

Is there an in-built way to clean up figure files after using matplotlib testing check_figures_equal decorator?

Using the example from the matplotlib.testing documentation, if this file:

@check_figures_equal()
def test_plot(fig_test, fig_ref):
    fig_test.subplots().plot([1, 3, 5])
    fig_ref.subplots().plot([0, 1, 2], [1, 3, 5])

is in some directory tests/functional/test_plotting.py, then after running this test (via pytest) it creates files of the form:

test_plot[png].png
test_plot[png]-expected.png
# etc...

in a directory result_images/test_plotting.

I understand that it needs these files for doing the image comparisons, but I was wondering if there's some option or additional fixture that can be applied to remove these files when the test is complete (rather than writing a custom clean-up fixture of some sort). It seems quite odd that it keeps them stored as permanent files when I don't see a need for these to be kept around.

Aucun commentaire:

Enregistrer un commentaire