Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

update testing helpers#16990

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

terencehonles
Copy link
Contributor

PR Summary

Pulling out of#16922 and expanding to be a bit more helpful (but will probably create additional discussion which I am am providing the context below)

  • @matplotlib.testing.decorators.image_comparison now prints the path to the diff image so it is easier to find, so that newcomers know it exists.
  • updatetests.py to give more information about how it should be run if matplotlib is not installed already.
  • updatematplotlib.test to return -1 instead of raising ImportErrors if there are preconditions not met. This allows the error messages to not be buried by the stack traces, is still a return value which would signify an error, and does not conflict with the range used bypytest.ExitCode (0-5) allowing callers to distinguish different pytest error codes from an error starting up pytest
  • move theimport pytest check out ofmatplotlib._init_tests because it is only called viamatplotlib.test and via pytest's configure handler, and it is more appropriate and can be handled more gracefully if it is checked inmatplotlib.test

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 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

- `@matplotlib.testing.decorators.image_comparison` now prints the path  to the diff image so it is easier to find, so that newcomers know it  exists.- update `tests.py` to give more information about how it should be run  if matplotlib is not installed already.- update `matplotlib.test` to return -1 instead of raising ImportErrors  if there are preconditions not met. This allows the error messages to  not be buried by the stack traces, is still a return value which would  signify an error, and does not conflict with the range used by  `pytest.ExitCode` (0-5) allowing callers to distinguish different  pytest error codes from an error starting up pytest- move the `import pytest` check out of `matplotlib._init_tests` because  it is only called via `matplotlib.test` and via pytest's configure  handler, and it is more appropriate and can be handled more gracefully  if it is checked in `matplotlib.test`

@cbook._delete_parameter("3.2", "switch_backend_warn")
@cbook._delete_parameter("3.3", "recursionlimit")
def test(verbosity=None, coverage=False, switch_backend_warn=True,
recursionlimit=0, **kwargs):
"""Run the matplotlib test suite."""
_init_tests()
Copy link
Member

Choose a reason for hiding this comment

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

But now you don't make the warning about FreeType. Why did thepytest import check have to move into this function and not just stay in_init_tests?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

You do still get the import warning about FreeType because the pytest configure calls_init_tests

matplotlib._init_tests()

As originally written the_init_tests will be called twice: Once before the logger is set up (here), and then again by pytest (linked above) which by then logging is being captured. I didn't believe_init_tests needed to be called here because it doesn't raise an exception and you're not going to see the logs since they aren't set up at this point. If the warning in_init_tests isn't actually a warning it should be emitted in a way that a user can see it (currently it isn't).

The reason I moved thepytest import into this function is so this function doesn't need to blindly captureImportError and canreturn -1 forpytest not being installed. This is all detailed in the PR description if you would like to read that.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@QuLogic thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

@QuLogic Does this satisfy your question? I've put this on the call agenda for tomorrow, but if you're ok with this, we don't have to spend time on it.

import pytest
except ImportError:
print("matplotlib.test requires pytest to run.")
return -1
Copy link
Member

Choose a reason for hiding this comment

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

I am skeptical about the API change, but this function is already returning an error code so any users of this will likely already be expecting to handle error codes so I expect it will do little harm.

Copy link
ContributorAuthor

@terencehonlesterencehonlesMay 13, 2020
edited
Loading

Choose a reason for hiding this comment

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

That was basically my position. It wasn't obvious to me why this was "broken" and I thought it wasn't used anymore. It was, but I didn't have the right environment. I then sought to clarify the whole process until getting pytest to run. I was contemplating keeping the same API for this part, but the code would be less clear and as you noted thetest function will already return error codes on pytest errors

@tacaswelltacaswell added this to thev3.3.0 milestoneMay 18, 2020
@tacaswelltacaswell merged commit1a6ef99 intomatplotlib:masterMay 18, 2020
@tacaswell
Copy link
Member

I am happy that the freetype checks are still happening viapytest_configure inconftest.py.

Thanks@terencehonles !

terencehonles reacted with thumbs up emoji

@terencehonlesterencehonles deleted the update-testing-helpers branchMay 19, 2020 02:42
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic left review comments

@timhoffmtimhoffmtimhoffm approved these changes

@tacaswelltacaswelltacaswell approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.3.0
Development

Successfully merging this pull request may close these issues.

4 participants
@terencehonles@tacaswell@QuLogic@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp