Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default hash savefig format #160

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pytest_mpl/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ConorMacBride We should make an issue to unpin this, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer need to change this.

mpldev: git+https://github.com/matplotlib/matplotlib.git#egg=matplotlib
extras =
test
Expand Down