-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
MNT/TST: generalize check_figures_equal to work with pytest.marks #15199
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
anntzer
merged 5 commits into
matplotlib:master
from
tacaswell:check_figures_equal_with_parametrize
Oct 4, 2019
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c0462a5
MNT/TST: generalize check_figures_equal to work with pytest.marks
tacaswell f082265
MNT: don't import from private pytest module
tacaswell 922b57f
MNT: fix spelling in test name
tacaswell cd4c42b
STY: condense code a bit
tacaswell e10850e
STY: condense code some more
tacaswell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
import warnings | ||
import pytest | ||
from matplotlib.testing.decorators import check_figures_equal | ||
|
||
@pytest.mark.xfail(strict=True, | ||
reason="testing that warnings fail tests") | ||
|
||
@pytest.mark.xfail( | ||
strict=True, reason="testing that warnings fail tests" | ||
) | ||
def test_warn_to_fail(): | ||
warnings.warn("This should fail the test") | ||
|
||
|
||
@pytest.mark.parametrize("a", [1]) | ||
@check_figures_equal(extensions=["png"]) | ||
@pytest.mark.parametrize("b", [1]) | ||
def test_paramatirize_with_check_figure_equal( | ||
tacaswell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
a, fig_ref, b, fig_test | ||
): | ||
assert a == b |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a side note, I find your code formatting style extremely hard to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this just looks like the worst of
black
, things likejust completely obfuscate the structure of the code -- compare with
(or with an additional newline after the opening parenthesis).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed black's doing.
Ironically, the biggest selling point of black for me is avoiding exactly these conversations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that it's automated doesn't absolve it from completely violating basic esthetics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw @NelleV and I have been trying to come up with a better automated scheme and it's certainly not trivial... Nevertheless, since afaict matplotlib hasn't added black as a dependency, it's a bit weird to add badly black-formatted code...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(And @tacaswell it looks like you've set it to 71c wide? Which is unconventional to say the least...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I personally just don't buy into the idea that code can be properly formatted without understanding the underlying semantics.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Juan is considering doing constrained reinforcement learning to learn the rules…)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I set it to 80c (to keep our pyflakes happy). Black does a slightly better job if you give it a bit more width to work with.