This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gwrtheyrn
Recipients gwrtheyrn
Date 2012-03-25.11:43:50
SpamBayes Score 1.0047518e-14
Marked as misclassified No
Message-id <1332675832.44.0.721741399942.issue14403@psf.upfronthosting.co.za>
In-reply-to
Content
Most assert statements of the unittest module provide both an assert statement as well as its inverse, like "assertIn" and "assertNotIn". There is apparently no such thing for exceptions.

I can do the following:

> with self.assertRaises(SomeException):
>     do_something()

But not:

> with self.assertRaisesNot(SomeException):
>     do_something()

I don't want to simply execute the code and hope that it doesn't raise an exception, because if it does, the test fails with an "error" status instead of a "failed" status.

A possible workaround is the following code:

> try:
>     do_something()
> except SomeException:
>     self.fail()

But that is not that expressive as an assert statement.

A naming alternative would be "assertDoesNotRaise".

In case this enhancement gets accepted, there should also be an inverse of "assertRaisesRegexp".
History
Date User Action Args
2012-03-25 11:43:52gwrtheyrnsetrecipients: + gwrtheyrn
2012-03-25 11:43:52gwrtheyrnsetmessageid: <1332675832.44.0.721741399942.issue14403@psf.upfronthosting.co.za>
2012-03-25 11:43:50gwrtheyrnlinkissue14403 messages
2012-03-25 11:43:50gwrtheyrncreate