<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
On 10/04/2010 01:54, Alfredo Deza wrote:
<blockquote
 cite="mid:g2l212f9b21004091754z3de01e7dlb22c0d82d43cfc94@mail.gmail.com"
 type="cite">Hi
  <div><br>
  </div>
  <div>I am having issues testing the constructor of a class that has a
try/except block.</div>
  <div><br>
  </div>
  <div>Should __init__ raise an exception so I can catch via
self.assertRaises to make it easier to test? Or are there other ways&nbsp;</div>
  <div>to make __init__ "testable"?</div>
  <div><br>
  </div>
  <div>What is the way you guys use the most (or like the best) for
testing __init__?</div>
</blockquote>
<br>
Well, avoiding doing things like that in constructors is one way to
make them more testable. Another way is to factor that code into a
separate method so that it can be stubbed out (test your constructor
calls it) and also tested separately.<br>
<br>
Michael<br>
<br>
<blockquote
 cite="mid:g2l212f9b21004091754z3de01e7dlb22c0d82d43cfc94@mail.gmail.com"
 type="cite">
  <div><br>
  </div>
  <div><br>
  </div>
  <div><br>
  </div>
  <div>Thanks!</div>
  <div><br>
  </div>
  <div><br clear="all">
  <br>
-- <br>
Alfredo Deza<br>
  <br>
  </div>
  <pre wrap=""><fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
testing-in-python mailing list
<a class="moz-txt-link-abbreviated"
 href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a>
<a class="moz-txt-link-freetext"
 href="http://lists.idyll.org/listinfo/testing-in-python">http://lists.idyll.org/listinfo/testing-in-python</a>
  </pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext"
 href="http://www.ironpythoninaction.com/">http://www.ironpythoninaction.com/</a>
<a class="moz-txt-link-freetext" href="http://www.voidspace.org.uk/blog">http://www.voidspace.org.uk/blog</a>

READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (&#8221;BOGUS AGREEMENTS&#8221;) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.

</pre>
</body>
</html>