unittest.assertRaise and keyword arguments?

Bo Peng bpeng at rice.edu
Fri Dec 2 21:11:04 CET 2005

Giovanni Bajo wrote:
> You can pass keyword arguments to assertRaises without problems:
> self.assertRaises(ValueError, myfunc, arg1,arg2, arg3, arg4, abc=0, foo=1,
> bar="hello")

Well, I though abc=0 would be keyword arguments for assertRaisers and 
never tried it!

> Or you can always do something like:
> self.assertRaises(ValueError, lambda: myfunc(arg1,arg2, arg3, arg4, abc=0,
> foo=1, bar="hello"))

This is also useful.

I now have nothing to complain against assertTaises. :-)


More information about the Python-list mailing list