@@ -479,28 +479,13 @@ def test_catch_warning_within_raise(self) -> None:
479
479
warnings .warn ("some warning" , category = FutureWarning )
480
480
raise ValueError ("some exception" )
481
481
482
+ def test_multiple_arg_custom_warning (self ) -> None :
483
+ class CustomWarning (UserWarning ):
484
+ def __init__ (self , a , b ):
485
+ pass
482
486
483
- def test_raise_type_error_on_non_string_warning () -> None :
484
- """Check pytest.warns validates warning messages are strings (#10865)."""
485
- with pytest .raises (TypeError , match = "Warning message must be str" ):
486
- with pytest .warns (UserWarning ):
487
- warnings .warn (1 ) # type: ignore
488
-
489
-
490
- def test_no_raise_type_error_on_string_warning () -> None :
491
- """Check pytest.warns validates warning messages are strings (#10865)."""
492
- with pytest .warns (UserWarning ):
493
- warnings .warn ("Warning" )
494
-
495
-
496
- @pytest .mark .skipif (
497
- hasattr (sys , "pypy_version_info" ),
498
- reason = "Not for pypy" ,
499
- )
500
- def test_raise_type_error_on_non_string_warning_cpython () -> None :
501
- # Check that we get the same behavior with the stdlib, at least if filtering
502
- # (see https://github.com/python/cpython/issues/103577 for details)
503
- with pytest .raises (TypeError ):
504
- with warnings .catch_warnings ():
505
- warnings .filterwarnings ("ignore" , "test" )
506
- warnings .warn (1 ) # type: ignore
487
+ with pytest .warns (CustomWarning ):
488
+ with pytest .raises (pytest .fail .Exception , match = "DID NOT WARN" ):
489
+ with pytest .warns (CustomWarning , match = "not gonna match" ):
490
+ a , b = 1 , 2
491
+ warnings .warn (CustomWarning (a , b ))
0 commit comments