def test_non_string_warning_argument(pytester: Pytester) -> None:
    """Non-str argument passed to warning breaks pytest (#2956)"""
    pytester.makepyfile(
        """\
        import warnings
        import pytest

        def test():
            warnings.warn(UserWarning(1, 'foo'))
        """
    )
    result = pytester.runpytest("-W", "always::UserWarning")
    result.stdout.fnmatch_lines(["*= 1 passed, 1 warning in *"])
Non-str argument passed to warning breaks pytest (#2956)
testing/test_warnings.py