On Tue, Jan 15, 2013 at 11:41 AM, Olemis Lang <span dir="ltr">&lt;<a href="mailto:olemis@gmail.com" target="_blank">olemis@gmail.com</a>&gt;</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&#39;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&#39;t understand why it&#39;s insufficient.  Here&#39;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&#39;re looking for the value of &#39;x&#39; in the case the exception is raised.  You could do at least these two things to examine the value of &#39;x&#39;:</div>
<div><br></div><div>1) assert the contents of the exception&#39;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&#39;s possible that I&#39;m just misunderstanding your problem, and if so, I&#39;m sorry.</div>
</div>