@@ -398,6 +398,33 @@ def test_argument_validation(self):
398398 with self .assertRaises (ValueError ):
399399 self .module .simplefilter ('ignore' , lineno = - 1 )
400400
401+ def test_invalid_category_types (self ):
402+ with self .assertRaises (TypeError ):
403+ self .module .filterwarnings ("ignore" , category = "notawarning" )
404+ with self .assertRaises (TypeError ):
405+ self .module .filterwarnings ("ignore" , category = 123 )
406+ with self .assertRaises (TypeError ):
407+ self .module .filterwarnings ("ignore" , category = 17.02 )
408+ with self .assertRaises (TypeError ):
409+ self .module .filterwarnings ("ignore" , category = True )
410+ with self .assertRaises (TypeError ):
411+ self .module .filterwarnings (
412+ "ignore" , category = (UserWarning , 17 )
413+ )
414+
415+ with self .assertRaises (TypeError ):
416+ self .module .simplefilter ("ignore" , category = "notawarning" )
417+ with self .assertRaises (TypeError ):
418+ self .module .simplefilter ("ignore" , category = 123 )
419+ with self .assertRaises (TypeError ):
420+ self .module .filterwarnings ("ignore" , category = 17.02 )
421+ with self .assertRaises (TypeError ):
422+ self .module .filterwarnings ("ignore" , category = True )
423+ with self .assertRaises (TypeError ):
424+ self .module .simplefilter (
425+ "ignore" , category = (UserWarning , 'abc' )
426+ )
427+
401428 def test_catchwarnings_with_simplefilter_ignore (self ):
402429 with self .module .catch_warnings (module = self .module ):
403430 self .module .resetwarnings ()
0 commit comments