def assert_coverage_warnings(
    warns: Iterable[warnings.WarningMessage],
    *msgs: str | re.Pattern[str],
) -> None:
    """
    Assert that the CoverageWarning's in `warns` have `msgs` as messages.

    Each msg can be a string compared for equality, or a compiled regex used to
    search the text.
    """
    assert msgs     # don't call this without some messages.
    warns = [w for w in warns if issubclass(w.category, CoverageWarning)]
    actuals = [cast(Warning, w.message).args[0] for w in warns]
    assert len(msgs) == len(actuals)
    for expected, actual in zip(msgs, actuals):
        if hasattr(expected, "search"):
            assert expected.search(actual), f"{actual!r} didn't match {expected!r}"
        else:
            assert expected == actual

    Assert that the CoverageWarning's in `warns` have `msgs` as messages.

    Each msg can be a string compared for equality, or a compiled regex used to
    search the text.
    
tests/helpers.py