[Python-Dev] Proposed unittest changes

Steve Holden steve at holdenweb.com
Fri Apr 18 00:53:51 CEST 2008


Guido van Rossum wrote:
> On Thu, Apr 17, 2008 at 3:31 PM, Jonathan Lange <jml at mumak.net> wrote:
>> On Thu, Apr 17, 2008 at 11:49 PM, Michael Foord
>>  <fuzzyman at voidspace.org.uk> wrote:
>>  >     assert_raises_with_message    (exc_class, message, callable, *args,
>>  >  **keywargs)
>>  >
>>
>>  I don't think this one should go in.
>>
>>  I think it would be better if assertRaises just returned the exception
>>  object that it catches. That way, you can test properties of the
>>  exception other than its message.
> 
> Hm. I've got to say that returning the exception object is, um, an odd
> API in the set of unittest APIs. I can see how it's sometimes more
> powerful, but I'd say that in many cases assertRaisesWithMessage will
> be easier to write and read. (And making it a regex match would be
> even cooler.)
> 
In which case assertRaisesMatching (and then eventually 
assert_raises_matching) might be a better name for it?

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/



More information about the Python-Dev mailing list