File tree 1 file changed +12
-7
lines changed
1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -388,15 +388,20 @@ def test_warns_context_manager_with_kwargs(self) -> None:
388
388
pass
389
389
assert "Unexpected keyword arguments" in str (excinfo .value )
390
390
391
- def _f ():
392
- warnings .warn ("some warning" , category = FutureWarning )
393
- raise ValueError ("some exception" )
391
+ @pytest .mark .parametrize ("err_type" , ["wrong_warn" , "missing_warn" ])
392
+ def test_catch_warning_within_raise (self , err_type ) -> None :
393
+ def wrong_warn ():
394
+ warnings .warn ("some warning" , category = FutureWarning )
395
+ raise ValueError ("some exception" )
394
396
395
- def _g ():
396
- raise ValueError ("some exception" )
397
+ def missing_warn ():
398
+ raise ValueError ("some exception" )
399
+
400
+ if err_type == "wrong_warn" :
401
+ func = wrong_warn
402
+ elif err_type == "missing_warn" :
403
+ func = missing_warn
397
404
398
- @pytest .mark .parametrize ("func" , [_f , _g ])
399
- def test_catch_warning_within_raise (self , func ) -> None :
400
405
with pytest .raises (pytest .fail .Exception ):
401
406
with pytest .warns (SyntaxWarning , match = "some warning" ):
402
407
with pytest .raises (ValueError , match = "some exception" ):
You can’t perform that action at this time.
0 commit comments