-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
ENH: implement matching warning message #37263
ENH: implement matching warning message #37263
Conversation
pandas/_testing.py
Outdated
@@ -2550,6 +2551,7 @@ def assert_produces_warning( | |||
filter_level="always", | |||
check_stacklevel=True, | |||
raise_on_extra_warnings=True, | |||
match=None, |
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.
can you annoate
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.
Annotated, but presumably the code became slightly less pythonic. Sorry for that.
], | ||
) | ||
def category(request): | ||
"""Return unique warning. |
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.
newline after """
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.
Fixed.
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.
comment, but ok to merge after @jbrockmendel doc-string comments.
pandas/_testing.py
Outdated
if raise_on_extra_warnings and extra_warnings: | ||
raise AssertionError( | ||
f"Caused unexpected warning(s): {repr(extra_warnings)}" | ||
) | ||
|
||
|
||
def _assert_raised_with_correct_stacklevel(actual_warning): |
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.
bonus points for typing
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.
Annotated. IMHO, the type warnings.WarningMessage
, although correct, has a confusing name for warning instance.
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.
Thanks for working on this!
@@ -0,0 +1,138 @@ | |||
"""" | |||
Test module for testing ``pandas._testing.assert_produces_warning``. | |||
""" |
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.
There is already a file with tests for this, in tests/util/test_assert_produces_warning.py
, can you move this there?
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.
Oh, I completely missed it. I moved tests as requested.
thanks @ivanovmg very nice |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Implement matching warning message.
New kwarg
match
inassert_produces_warning
.