B017 support the matches keyword argument to pytest.raises
toofar opened this issue · comments
toofar commented
#317 added support for warning about B017 when using pytest.raises(Exception)
, and it included an exception for passing a regex to match against similar to unittest.assertRaisesRegex. But you can pass that regex as a keyword argument too and that exception doesn't apply in that case.
Docs with an example of passing the match
keyword: https://docs.pytest.org/en/7.1.x/how-to/assert.html#assertions-about-expected-exceptions
Reproducer:
import pytest
def test_positional_arg():
with pytest.raises(Exception, 'some-regex'): # this is fine
pass
def test_keyword_arg():
with pytest.raises(Exception, match='some-regex'): # this gets a B017 warning
pass