Skip to content

DOC: clarify that assert_produces_warning can take multiple warnings #47829

Closed
@MarcoGorelli

Description

@MarcoGorelli

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Testingpandas testing functions or related to the test suiteWarningsWarnings that appear or should be added to pandasgood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions