restore deleted tests
This commit is contained in:
parent
497ffc51c1
commit
02c3fffc49
|
@ -479,7 +479,34 @@ class TestWarns:
|
||||||
warnings.warn("some warning", category=FutureWarning)
|
warnings.warn("some warning", category=FutureWarning)
|
||||||
raise ValueError("some exception")
|
raise ValueError("some exception")
|
||||||
|
|
||||||
def test_multiple_arg_custom_warning(self) -> None:
|
|
||||||
|
def test_raise_type_error_on_non_string_warning() -> None:
|
||||||
|
"""Check pytest.warns validates warning messages are strings (#10865)."""
|
||||||
|
with pytest.raises(TypeError, match="Warning message must be str"):
|
||||||
|
with pytest.warns(UserWarning):
|
||||||
|
warnings.warn(1) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
def test_no_raise_type_error_on_string_warning() -> None:
|
||||||
|
"""Check pytest.warns validates warning messages are strings (#10865)."""
|
||||||
|
with pytest.warns(UserWarning):
|
||||||
|
warnings.warn("Warning")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
hasattr(sys, "pypy_version_info"),
|
||||||
|
reason="Not for pypy",
|
||||||
|
)
|
||||||
|
def test_raise_type_error_on_non_string_warning_cpython() -> None:
|
||||||
|
# Check that we get the same behavior with the stdlib, at least if filtering
|
||||||
|
# (see https://github.com/python/cpython/issues/103577 for details)
|
||||||
|
with pytest.raises(TypeError):
|
||||||
|
with warnings.catch_warnings():
|
||||||
|
warnings.filterwarnings("ignore", "test")
|
||||||
|
warnings.warn(1) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
def test_multiple_arg_custom_warning(self) -> None:
|
||||||
"""Test for issue #11906."""
|
"""Test for issue #11906."""
|
||||||
|
|
||||||
class CustomWarning(UserWarning):
|
class CustomWarning(UserWarning):
|
||||||
|
|
Loading…
Reference in New Issue