[Python-Dev] unittest missing assertNotRaises
Wilfred Hughes
wilfred at potatolondon.com
Wed Sep 28 12:20:54 CEST 2011
On 27 September 2011 19:59, Laurens Van Houtven <_ at lvh.cc> wrote:
> Sure, you just *do* it. The only advantage I see in assertNotRaises is that when that exception is raised, you should (and would) get a failure, not an error.
It's a useful distinction. I have found myself writing code of the form:
def test_old_exception_no_longer_raised(self):
try:
do_something():
except OldException:
self.assertTrue(False)
in order to distinguish between a regression and something new
erroring. The limitation of this pattern is that the test failure
message is not as good.
More information about the Python-Dev
mailing list