On Tue, Jan 15, 2013 at 11:41 AM, Olemis Lang <span dir="ltr"><<a href="mailto:olemis@gmail.com" target="_blank">olemis@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
No that's not the case as I want to detect whether expected exception<br>
was not raised or any other kind of failure .<br>
<div class="im"><br></div></blockquote><div><br></div><div>I don't understand why it's insufficient. Here's your problem, as I understand it:</div><div><br></div><div>1) you want to check for the type and existence of an exception</div>
<div>2) you want to guarantee that the raised exception has some specific information, beyond just its type</div><div><br></div><div>#1 above is already handled by unittest2.assertRaises. #2 is easily attained, if I understand correctly that you're looking for the value of 'x' in the case the exception is raised. You could do at least these two things to examine the value of 'x':</div>
<div><br></div><div>1) assert the contents of the exception's message</div><div>2) give the exception object an attribute for the relevant value, which you will assert</div><div><br></div><div>In either case, you will end up with a descriptive assertion failure message showing what went wrong.</div>
<div><br></div><div>I have created an example here: <a href="https://gist.github.com/4541594">https://gist.github.com/4541594</a></div><div><br></div><div>It's possible that I'm just misunderstanding your problem, and if so, I'm sorry.</div>
</div>