New submission from Denver Coneybeare <denver.coneybe...@gmail.com>:

It would be great if unittest.assertRaises() returned the raised exception when 
it passes.  This allows the caller to easily perform further checks on the 
exception, such as its attribute values.  Currently assertRaises() returns None 
(when it doesn't return a context manager) so changing the return value should 
not break backwards compatibility.

I see that this was already discussed in issue6275 but I'd like to resurrect 
the discussion since this is a common scenario in my unit tests, and I assume 
others.  Revisions r76238 and r78110 added the ability to get the exception 
from the context manager (good) but sometimes using the context manager 
approach adds unnecessary bloat to already long-winded unit tests.

I've attached a possible patch for the py3k branch 
(unittest.assertRaises.returnex.v1.patch).  Thank you for (re)considering this 
topic :)  Also, thank you Michael Foord for your recent improvements to 
unittest... the new features are very much appreciated!

----------
components: Library (Lib)
files: unittest.assertRaises.returnex.v1.patch
keywords: patch
messages: 113781
nosy: denversc, krisvale, michael.foord
priority: normal
severity: normal
status: open
title: unittest.assertRaises() return the raised exception
type: feature request
versions: Python 3.2
Added file: 
http://bugs.python.org/file18501/unittest.assertRaises.returnex.v1.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9587>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to