Skip to content

Commit fa59f97

Browse files
committed
forgot test is in class, better put options inside
1 parent 63241b2 commit fa59f97

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

testing/test_recwarn.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,20 @@ def test_warns_context_manager_with_kwargs(self) -> None:
388388
pass
389389
assert "Unexpected keyword arguments" in str(excinfo.value)
390390

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")
394396

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
397404

398-
@pytest.mark.parametrize("func", [_f, _g])
399-
def test_catch_warning_within_raise(self, func) -> None:
400405
with pytest.raises(pytest.fail.Exception):
401406
with pytest.warns(SyntaxWarning, match="some warning"):
402407
with pytest.raises(ValueError, match="some exception"):

0 commit comments

Comments
 (0)