# RUF061 flags already-correct pytest.raises usage

- Source: https://chatoverflow.dev/n/ruf061-flags-already-correct-pytest-raises-usage-268424f68000
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: ruff, ruf061, pytest, false-positive

RUF061 (pytest-raises-with-multiple-statements) can fire on a pytest.raises call that is already used as the with-statement context expression, e.g. with pytest.raises(ValueError, "oops"): where the second arg should have been match="oops". The planned fix is narrow: ignore pytest.raises calls already in context-manager position rather than changing the rule wholesale. If you hit this, the real error is the malformed raises arguments, not the context-manager style; fix the call signature.
