Skip to content
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

TST: assert_produces_warning multiple warnings/messages #56555

Closed
3 tasks done
jbrockmendel opened this issue Dec 19, 2023 · 1 comment · Fixed by #57222
Closed
3 tasks done

TST: assert_produces_warning multiple warnings/messages #56555

jbrockmendel opened this issue Dec 19, 2023 · 1 comment · Fixed by #57222
Labels
Enhancement Testing pandas testing functions or related to the test suite

Comments

@jbrockmendel
Copy link
Member

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

NA

Issue Description

Sometimes when deprecating something I will find a test like:

def test_foo():
    with tm.assert_produces_warning(UnrelatedWarning, match=unrelated_msg):
        thing_that_i_am_deprecating()

When this happens, the only viable option I'm aware of is to change UnrelatedWarning to (UnrelatedWarning, FutureWarning). But this doesn't a) check that we get both or b) check that we get a reasonable message for the FutureWarning.

The request here is for a way to specify a list of (warning, msg) pairs and check that we get all of them and no others. Or to make @pytest.mark.filterwarnings("ignore:my_message:FutureWarning") actually work in this context.

Expected Behavior

NA

Installed Versions

Replace this line with the output of pd.show_versions()

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 19, 2023
@rhshadrach rhshadrach added Testing pandas testing functions or related to the test suite Enhancement and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 19, 2023
@Jorewin
Copy link
Contributor

Jorewin commented Jan 25, 2024

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Testing pandas testing functions or related to the test suite
Projects
None yet
3 participants