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 kristjan.jonsson
Recipients denversc, kristjan.jonsson, michael.foord
Date 2010-08-16.09:28:23
SpamBayes Score 2.1130445e-05
Marked as misclassified No
Message-id <1281950906.13.0.0474102981847.issue9587@psf.upfronthosting.co.za>
In-reply-to
Content
Pehaps it hasn't been demonstrated before, but just for the sake of argument (and because I'm a persistant bugger), here are the two different cases:

current:
ctxt = self.assertRaises(MyException)
with ctxt:
    foo()
self.assertEqual(ctxt.exception.value, 1)

suggested:
e = self.assertRaises(MyExcetpion, foo)
self.assertEqual(e.value, 1)

The inconvenient bit about the current method is having to keep the context manager around.  Also note that the current way of looking at the exception object makes it blatantly clear that self.assertRaises() is returning an object.  That, imho, breaks the argument about self.assert* methods not returning any info.
History
Date User Action Args
2010-08-16 09:28:26kristjan.jonssonsetrecipients: + kristjan.jonsson, michael.foord, denversc
2010-08-16 09:28:26kristjan.jonssonsetmessageid: <1281950906.13.0.0474102981847.issue9587@psf.upfronthosting.co.za>
2010-08-16 09:28:24kristjan.jonssonlinkissue9587 messages
2010-08-16 09:28:23kristjan.jonssoncreate