Skip to content

Update use of pytest.raises to include match keyword

We should update the common pattern:

with pytest.raises(Exception) as exc:
    thing()
assert str(exc.value) == message

to use the supported match keyword for pytest.raises, see https://docs.pytest.org/en/7.1.x/how-to/assert.html#assertions-about-expected-exceptions.

The pattern would then be

with pytest.raises(Exception, match=message):
    thing()