matplotlib / matplotlib/pytest-mpl

Support hierarchical tests

Open
#85 2 comments 1 reaction 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

Hi,

I am working a lot with images and therefore love the idea of the project. I played around with it a little bit and noticed something.

When I group my tests in classes, the image file gets named only after the function that calls it.

Example:

class Test_Imageutils:
    @pytest.mark.mpl_image_compare
    def test_put_text(self):
        from skimage import data
        astronaut = data.astronaut()
        annotated = imageutils.put_text(astronaut.copy(), "hi", loc="center")
        fig, ax = plt.subplots(1, 1, figsize=(6, 6))
        ax.imshow(annotated)
        return fig

And the image in baseline is named test_put_text.png

I think it would be a great idea to add an option to write the full hierarchy, either into folders or into the file name. For example

  • baseline/Test_Imageutils/test_put_text.png
  • baseline/Test_Imageutils-test_put_text.png

What do you think?

I could dig a little into the code and come up with a PR if anyone thinks it is a good idea.

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 by locating the code that derives baseline image names from pytest tests, using the Test_Imageutils/test_put_text example as the expected case. Compare the folder and filename approaches described in the issue, then define the option and verify that hierarchical names are generated consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.