Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make more of testing/ pytest-independent. #14562

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

Closed
wants to merge 1 commit into from

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jun 17, 2019

PR Summary

This makes it actually possible to write tests independently of pytest
(the API is still private, but could be made public):

import unittest
from matplotlib import pyplot as plt
from matplotlib.testing.decorators import _make_image_comparator

class TestFoo(unittest.TestCase):

    @_make_image_comparator(baseline_images=["foo"], extension="png")
    def test_bar(self):
        fig, ax = plt.subplots()

works as expected.

See also discussion starting at https://gitter.im/matplotlib/matplotlib?at=5d064454a8d9871b3299790a.

Depends on #14338.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@timhoffm
Copy link
Member

Can you please clarify what this achieves or is aspiring?

Matplotlib's own tests will depend on pytest in the foreseeable future and there's no reason to change this. So, for ourselves, this change gains nothing.
I'm unclear on third-party libraries. There is pytest-mpl and it is/used to be(?) possible to use matplotlibs own testing functions to test images in third-party libraries. I fully agree, that there should be an official way how to test plots outside of Matplotlib. But shouldn't we first define what that should be before we start working that way?

@anntzer
Copy link
Contributor Author

anntzer commented Jun 17, 2019

Sorry for the lack of clarity.
This PR was basically written in response #14329; see in particular #14329 (comment).
[edit: sorry, misclicked and accidentally requested a review from you (now cancelled), please ignore]

@anntzer anntzer requested review from timhoffm and removed request for timhoffm June 23, 2019 11:18
@anntzer anntzer force-pushed the moreimagecomparisontest branch 2 times, most recently from f28bc2d to b0d5f41 Compare June 24, 2019 07:08
@anntzer anntzer force-pushed the moreimagecomparisontest branch 2 times, most recently from ae97b3e to ed4eaf1 Compare July 18, 2019 16:44
@tacaswell tacaswell added this to the v3.3.0 milestone Aug 24, 2019
@anntzer anntzer force-pushed the moreimagecomparisontest branch from ed4eaf1 to 7ff4d34 Compare December 13, 2019 17:02
@QuLogic QuLogic modified the milestones: v3.3.0, v3.4.0 May 2, 2020
This makes it actually possible to write tests independently of pytest
(the API is still private, but could be made public):

```
import unittest
from matplotlib import pyplot as plt
from matplotlib.testing.decorators import _make_image_comparator

class TestFoo(unittest.TestCase):

    @_make_image_comparator(baseline_images=["foo"], extension="png")
    def test_bar(self):
        fig, ax = plt.subplots()
```

works as expected.
@anntzer anntzer force-pushed the moreimagecomparisontest branch from 7ff4d34 to 4b55644 Compare May 2, 2020 05:31
@QuLogic QuLogic modified the milestones: v3.4.0, v3.5.0 Jan 22, 2021
@jklymak jklymak marked this pull request as draft May 8, 2021 17:09
@jklymak
Copy link
Member

jklymak commented May 8, 2021

is this really something you want to pursue? I'm not following what its for either...

@anntzer
Copy link
Contributor Author

anntzer commented May 8, 2021

I'll try to break this down into smaller parts.

@anntzer anntzer closed this May 8, 2021
@anntzer anntzer deleted the moreimagecomparisontest branch May 8, 2021 20:14
@QuLogic QuLogic modified the milestones: v3.5.0, unassigned May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants