Re: [Pyunit-interest] Assert that an Exception is NOT raised.
Brought to you by:
purcell
From: Timothy G. <tj...@cr...> - 2002-12-11 16:13:52
|
Thanks Noah, I think I might be able to make that work. The situation is this, I'm working on some code that while broken will raise an AttributeError Exception. I want to make a FAILED test, right now I get an ERROR test. Problem is, I only want to check for an AttributeError, cause other Exceptions should cause and ERROR test not a FAILED test. On Wed, 2002-12-11 at 06:47, Noah Spurrier wrote: > I'm not sure if I read your question right, but the follow code is > what I use to test for an exception NOT being raised. >=20 >=20 > class MissingExceptionTestCase (unittest.TestCase): > def testMissingException (self): > try: > do_something_stupid_that_should_raise_an_exception () > except Exception: > pass > else: > self.fail ('An Exception was expected, but it was not raised.= This is bad.') >=20 >=20 > Yours, > Noah >=20 > ----- Original Message -----=20 > From: "Timothy Grant" <tj...@cr...> > To: <pyu...@li...> > Sent: Tuesday, December 10, 2002 10:07 PM > Subject: [Pyunit-interest] Assert that an Exception is NOT raised. >=20 >=20 >=20 --=20 Stand Fast, tjg. Timothy Grant www.craigelachie.org |