matplotlib / matplotlib/pytest-mpl

default savefig format

Open
#152 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
272
Forks
53
PR merge metrics
No merged PRs in 30d

Description

In the process of penning #150, I noticed that when capturing the test image to an io.Bytes in-memory buffer:

https://github.com/matplotlib/pytest-mpl/blob/e3876180847c2d04aeda1982372074998a7f8716/pytest_mpl/plugin.py#L419-L421

That the format kwarg to savefig isn't used.

Would you be adverse to defaulting to format='png', particularly when writing to a buffer, as (from what I understand) matplotlib will default to the rcParams to select the file-format to save to the buffer for the image, and this could be a source confusion/issues for hashing repeatability for developers when testing.

i.e., what I'm proposing is that a format='png' is injected into the savefig_kwargs, iff not specified by the caller as a kwarg option in the marker decorator.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pytest_mpl/plugin.py at the linked savefig call around lines 419–421, then trace how savefig_kwargs comes from the marker decorator. Check how the in-memory buffer is handled and verify that the default format is PNG while a caller-provided format remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
testing-qa
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.