Skip to content

Improve error message on failing test_pyplot_up_to_date #12537

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

Merged
merged 2 commits into from
Nov 3, 2018

Conversation

timhoffm
Copy link
Member

@timhoffm timhoffm commented Oct 16, 2018

PR Summary

test_pyplot_up_to_date() produces a long error message, but it's hard for the inexperienced contributor to understand what is going wrong and how to fix it.

This PR produces a shorter and more meaningful error message.

@timhoffm timhoffm force-pushed the pyplot-test-message branch from 5f874a2 to f42c016 Compare October 16, 2018 20:38
fromfile='found pyplot.py',
tofile='expected pyplot.py',
n=0, lineterm=''))
raise AssertionError(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can use either

assert success_cond, error_msg

or

if fail_cond: pytest.fail(error_msg)

either of which seem mildly preferable to throwing AssertionError explicitly.

n=0, lineterm=''))
raise AssertionError(
"pyplot.py is not up-to-date. Please run "
"'python tools/boilerplate.py' to update pyplot.py. "
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this typically needs to be done from an environment where the current matplotlib is installed (e.g. pip install -e'd).

Copy link
Member Author

@timhoffm timhoffm Oct 19, 2018

Choose a reason for hiding this comment

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

Done for now. Should we modify boilerplate.py to import the adjacent matplotlib, even if it is not installed? IMO it makes sense to import local if we want to update the local pyplot.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we modify boilerplate.py to import the adjacent matplotlib, even if it is not installed? IMO it makes sense to import local if we want to update the local pyplot.

But you have no guarantees that e.g. the extension modules are built, so you can fail with ImportError. Seems easier to just ask for it to be installed...

@dstansby dstansby added this to the v3.1 milestone Nov 3, 2018
@dstansby dstansby merged commit 4c3c724 into matplotlib:master Nov 3, 2018
@timhoffm timhoffm deleted the pyplot-test-message branch November 3, 2018 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants