How to expect a specific exception with Pytest's xfail?
Use xfail
with the raises
param.
from pytest import mark
@mark.xfail(raises=RuntimeError)
def test_func() -> None:
func()
While this works, unfortunately it won’t let you say exactly where it’s expected to be raised in the test.