Summary
The documentation for pytest-raises-without-exception (PT010) says:
pytest.raises expects to receive an expected exception as its first argument. If omitted, the pytest.raises call will fail at runtime.
As of pytest 8.4.0 (released June 2, 2025) it is also sufficient to pass the keyword argument match or check. The rule should recognize those arguments too.
$ cat >pt010.py <<'# EOF'
import pytest
with pytest.raises(match=r"!+"):
raise RuntimeError("!!!")
with pytest.raises(check=lambda _e: True):
raise RuntimeError("...")
# EOF
$ python pt010.py; echo $?
0
$ ruff --isolated check pt010.py --select PT010 --output-format concise -q
pt010.py:2:6: PT010 Set the expected exception in `pytest.raises()`
pt010.py:4:6: PT010 Set the expected exception in `pytest.raises()`
Version
ruff 0.11.13 (5faf72a 2025-06-05)
Summary
The documentation for
pytest-raises-without-exception(PT010) says:As of pytest 8.4.0 (released June 2, 2025) it is also sufficient to pass the keyword argument
matchorcheck. The rule should recognize those arguments too.Version
ruff 0.11.13 (5faf72a 2025-06-05)