[Python-Dev] unittest missing assertNotRaises

Oleg Broytman phd at phdru.name
Wed Sep 28 12:51:00 CEST 2011


On Wed, Sep 28, 2011 at 09:43:13AM +1000, Steven D'Aprano wrote:
> Oleg Broytman wrote:
> >On Tue, Sep 27, 2011 at 07:46:52PM +0100, Wilfred Hughes wrote:
> >>+    def assertNotRaises(self, excClass, callableObj=None, *args, **kwargs):
> >>+        """Fail if an exception of class excClass is thrown by
> >>+        callableObj when invoked with arguments args and keyword
> >>+        arguments kwargs.
> >>+        +        """
> >>+        try:
> >>+            callableObj(*args, **kwargs)
> >>+        except excClass:
> >>+            raise self.failureException("%s was raised" % excClass)
> >>+            +

> But I can't see this being a useful test.

   Me too.

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            phd at phdru.name
           Programmers don't die, they just GOSUB without RETURN.


More information about the Python-Dev mailing list