assertraises behaviour

Andrea Crotti andrea.crotti.0 at gmail.com
Tue Jul 17 19:31:24 EDT 2012


To clarify my "problem", I just thought that assertRaises if used as 
context manager should behave as following:
- keep going if the exception declared is raised
- re-raise an error even if catched after the declared exception was catched

I was also confused by the doc a bit:
"Test that an exception is raised when /callable/ is called with any 
positional or keyword arguments that are also passed to assertRaises() 
<http://docs.python.org/library/unittest.html#unittest.TestCase.assertRaises>. 
The test passes if /exception/ is raised, is an error if another 
exception is raised, or fails if no exception is raised"

which speaks about when it's not used as a context manager..

I understand why it's not possible and it's not a big issue though..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120718/2c0cef3b/attachment.html>


More information about the Python-list mailing list