{"id":13542146,"url":"https://github.com/matplotlib/pytest-mpl","last_synced_at":"2025-06-12T08:38:24.717Z","repository":{"id":34200759,"uuid":"38056556","full_name":"matplotlib/pytest-mpl","owner":"matplotlib","description":"A pytest plugin to facilitate image comparison for Matplotlib figures","archived":false,"fork":false,"pushed_at":"2025-05-26T21:57:11.000Z","size":2658,"stargazers_count":253,"open_issues_count":47,"forks_count":48,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-06-08T12:28:36.884Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matplotlib.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-06-25T15:09:39.000Z","updated_at":"2025-05-30T12:13:56.000Z","dependencies_parsed_at":"2023-02-16T11:16:18.401Z","dependency_job_id":"6161307d-b0a1-45a4-af86-d649912d3917","html_url":"https://github.com/matplotlib/pytest-mpl","commit_stats":{"total_commits":489,"total_committers":29,"mean_commits":"16.862068965517242","dds":0.6094069529652352,"last_synced_commit":"29fd89095ced454e1f82007aeb592268a430aba0"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/matplotlib/pytest-mpl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matplotlib%2Fpytest-mpl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matplotlib%2Fpytest-mpl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matplotlib%2Fpytest-mpl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matplotlib%2Fpytest-mpl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matplotlib","download_url":"https://codeload.github.com/matplotlib/pytest-mpl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matplotlib%2Fpytest-mpl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259431618,"owners_count":22856565,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T10:01:01.992Z","updated_at":"2025-06-12T08:38:24.676Z","avatar_url":"https://github.com/matplotlib.png","language":"Python","readme":"``pytest-mpl``\n==============\n\n``pytest-mpl`` is a `pytest \u003chttps://docs.pytest.org\u003e`__ plugin to facilitate image comparison for `Matplotlib \u003chttp://www.matplotlib.org\u003e`__ figures.\n\nFor each figure to test, an image is generated and then subtracted from an existing reference image.\nIf the RMS of the residual is larger than a user-specified tolerance, the test will fail.\nAlternatively, the generated image can be hashed and compared to an expected value.\n\nFor more information, see the `pytest-mpl documentation \u003chttps://pytest-mpl.readthedocs.io\u003e`__.\n\nInstallation\n------------\n.. code-block:: bash\n\n   pip install pytest-mpl\n\nFor detailed instructions, see the `installation guide \u003chttps://pytest-mpl.readthedocs.io/en/latest/installing.html\u003e`__ in the ``pytest-mpl`` docs.\n\nUsage\n-----\nFirst, write test functions that create a figure.\nThese image comparison tests are decorated with ``@pytest.mark.mpl_image_compare`` and return the figure for testing:\n\n.. code-block:: python\n\n   import matplotlib.pyplot as plt\n   import pytest\n\n   @pytest.mark.mpl_image_compare\n   def test_plot():\n       fig, ax = plt.subplots()\n       ax.plot([1, 2])\n       return fig\n\nThen, generate reference images by running the test suite with the ``--mpl-generate-path`` option:\n\n.. code-block:: bash\n\n   pytest --mpl-generate-path=baseline\n\nThen, run the test suite as usual, but pass ``--mpl`` to compare the returned figures to the reference images:\n\n.. code-block:: bash\n\n   pytest --mpl\n\nBy also passing ``--mpl-generate-summary=html``, a summary of the image comparison results will be generated in HTML format:\n\n+---------------+---------------+---------------+\n| |html all|    | |html filter| | |html result| |\n+---------------+---------------+---------------+\n\nFor more information on how to configure and use ``pytest-mpl``, see the `pytest-mpl documentation \u003chttps://pytest-mpl.readthedocs.io\u003e`__.\n\nContributing\n------------\n``pytest-mpl`` is a community project maintained for and by its users.\nThere are many ways you can help!\n\n- Report a bug or request a feature `on GitHub \u003chttps://github.com/matplotlib/pytest-mpl/issues\u003e`__\n- Improve the documentation or code\n\n.. |html all| image:: docs/images/html_all.png\n.. |html filter| image:: docs/images/html_filter.png\n.. |html result| image:: docs/images/html_result.png\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatplotlib%2Fpytest-mpl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatplotlib%2Fpytest-mpl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatplotlib%2Fpytest-mpl/lists"}