test: Add test for iterator exhaustion with next#2273
Merged
Conversation
* Add test to tests/contrib/test_viz.py to cover the case where the wrong labels are somehow returned in brazil.plot_results, causing the legend label ordering logic to fail. * Amends PR # 2264
matthewfeickert
commented
Aug 10, 2023
Comment on lines
+197
to
+203
| get_legend_handles_labels = mocker.patch( | ||
| "matplotlib.axes._axes.Axes.get_legend_handles_labels", | ||
| return_value=(None, ["fail"]), | ||
| ) | ||
|
|
||
| with pytest.raises(StopIteration): | ||
| brazil.plot_results(data["testmus"], data["results"], test_size=0.05, ax=ax) |
Member
Author
There was a problem hiding this comment.
This really just causes the error to cover the iterator exhaustion case for next and so is somewhat of a bad test, but we'd need to add a custom exception here otherwise and I'm not sure if that is worth it.
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## main #2273 +/- ##
==========================================
+ Coverage 98.27% 98.30% +0.02%
==========================================
Files 69 69
Lines 4534 4534
Branches 801 801
==========================================
+ Hits 4456 4457 +1
Misses 45 45
+ Partials 33 32 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
kratsg
approved these changes
Aug 10, 2023
Contributor
|
I'm ok with the test looking like this, since this doesn't necessarily mean an impact in actual user-facing code. |
4 tasks
matthewfeickert
added a commit
that referenced
this pull request
Aug 16, 2023
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
tests/contrib/test_viz.pyto cover the case where the wrong labels are somehow returned inbrazil.plot_results, causing the legend label ordering logic to fail.Checklist Before Requesting Reviewer
Before Merging
For the PR Assignees: