[pytest-dev] Allow pytest.raises to assert about exception arguments

Vladimir Keleshev vladimir at keleshev.com
Mon Oct 14 17:19:12 CEST 2013


Right now one of my code-bases is filled with assertions like:

with raises(SpecificError) as error:
    some_action()
assert 'specific message' == str(error)

Why not change `raises` to allow instances of exceptions as well:

with raises(SpecificError('specific message')):
    some_action()

I think, this can improve readability of `raises` assertions. Can't even think of immediate downsides of this.

What do you think?

—Vladimir


More information about the Pytest-dev mailing list