From 84dfe3256d39e9dd0adca1ecea08cd29a8fdb001 Mon Sep 17 00:00:00 2001 From: Bill Little Date: Sat, 21 May 2022 23:02:19 +0100 Subject: [PATCH 1/2] default hash savefig format --- pytest_mpl/plugin.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pytest_mpl/plugin.py b/pytest_mpl/plugin.py index fd8fe03c..0e022509 100644 --- a/pytest_mpl/plugin.py +++ b/pytest_mpl/plugin.py @@ -46,6 +46,9 @@ from pytest_mpl.summary.html import generate_summary_basic_html, generate_summary_html +#: The default savefig format when generating an image hash. +DEFAULT_FORMAT = 'png' + SUPPORTED_FORMATS = {'html', 'json', 'basic-html'} SHAPE_MISMATCH_ERROR = """Error: Image dimensions did not match. @@ -416,6 +419,9 @@ def generate_image_hash(self, item, fig): compare = self.get_compare(item) savefig_kwargs = compare.kwargs.get('savefig_kwargs', {}) + if 'format' not in savefig_kwargs: + savefig_kwargs['format'] = DEFAULT_FORMAT + imgdata = io.BytesIO() fig.savefig(imgdata, **savefig_kwargs) From 693893b39eb57b692150a38a0ac1e7e30ad7c4a5 Mon Sep 17 00:00:00 2001 From: Bill Little Date: Sun, 22 May 2022 00:40:05 +0100 Subject: [PATCH 2/2] pin to mpl=3.5.1 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 774cc0f9..47bbf80d 100644 --- a/tox.ini +++ b/tox.ini @@ -26,7 +26,7 @@ deps = mpl32: matplotlib==3.2.* mpl33: matplotlib==3.3.* mpl34: matplotlib==3.4.* - mpl35: matplotlib==3.5.* + mpl35: matplotlib==3.5.1 mpldev: git+https://github.com/matplotlib/matplotlib.git#egg=matplotlib extras = test