-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Testingpandas testing functions or related to the test suitepandas testing functions or related to the test suiteWarningsWarnings that appear or should be added to pandasWarnings that appear or should be added to pandasgood first issue
Description
Noticed in #47828 (comment)
Currently, it's possible to match multiple warnings, by passing them as a tuple. But, this isn't documented, nor do the types suggest it:
Example:
import warnings
import pytest
import pandas._testing as tm
def me():
warnings.warn('foo', FutureWarning)
warnings.warn('bar', UserWarning)
def test_1():
with tm.assert_produces_warning((FutureWarning, UserWarning), match=r'foo|bar'):
me()
So, the issue would be:
- in
pandas/pandas/_testing/_warnings.py
Lines 19 to 27 in 8c7b0b2
def assert_produces_warning( expected_warning: type[Warning] | bool | None = Warning, filter_level: Literal[ "error", "ignore", "always", "default", "module", "once" ] = "always", check_stacklevel: bool = True, raise_on_extra_warnings: bool = True, match: str | None = None, ): expected_warning
so it can also beTuple[Type[Warning], ...]
- add a test to https://github.com/pandas-dev/pandas/blob/main/pandas/tests/util/test_assert_produces_warning.py for when matching multiple warnings
Metadata
Metadata
Assignees
Labels
Testingpandas testing functions or related to the test suitepandas testing functions or related to the test suiteWarningsWarnings that appear or should be added to pandasWarnings that appear or should be added to pandasgood first issue