<br><br><div class="gmail_quote">On Tue, Jan 19, 2010 at 11:14 AM, Alfredo Deza <span dir="ltr">&lt;<a href="mailto:arufuredosan@gmail.com">arufuredosan@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Red<br><br>Can you try an give me some examples? I think I am not following you correctly...<div><div></div><div class="h5"><br><br><div class="gmail_quote">On Mon, Jan 18, 2010 at 10:05 PM, Red Forks <span dir="ltr">&lt;<a href="mailto:redforks@gmail.com" target="_blank">redforks@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><br><br><div class="gmail_quote"><div>On Tue, Jan 19, 2010 at 10:37 AM, Alfredo Deza <span dir="ltr">&lt;<a href="mailto:arufuredosan@gmail.com" target="_blank">arufuredosan@gmail.com</a>&gt;</span> wrote:<br>

</div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><div><div></div><div>
I am building some tests for a Python installer that copies some files and changes some permissions.<br><br>Nothing weird there.<br><br>However, in the test class I am starting with a setUp that basically calls the installer (so the tests can see if everything is where it should be), this is followed by a few assertions and finally a tearDown is called where everything gets uninstalled.<br>



<br>When running the tests with nosetests, I see that setUp and tearDown are called for *every* method in my test class (e.g. installs =&gt; runs test method =&gt; uninstalls ....)<br><br>Isn&#39;t setUp supposed to be run once at the beginning of the class? or is this expected?<br>



<br>In case this is expected, is there a way to do it <b>just once </b>for all the methods?<br><br><br>
<br></div></div><div>_______________________________________________<br>
testing-in-python mailing list<br>
<a href="mailto:testing-in-python@lists.idyll.org" target="_blank">testing-in-python@lists.idyll.org</a><br>
<a href="http://lists.idyll.org/listinfo/testing-in-python" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
<br></div></blockquote></div><div><div></div><div><br><div>Maybe you need module level setup / teapDown func.</div>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br><div><a href="http://somethingaboutorange.com/mrl/projects/nose/0.11.0/writing_tests.html">http://somethingaboutorange.com/mrl/projects/nose/0.11.0/writing_tests.html</a></div><div><br>
</div><div>Method 1: using module level setup / teardown:</div><div><br></div><div>def setup():</div><div>   # setup codes here</div><div><br></div><div>def teardown():</div><div>   # teardown codes here</div><div><br></div>
<div>class YourTestClass(TestCase):</div><div>    pass</div><div><br></div><div>Method 2: class level setup / teardown</div><div><br></div><div>class YourTestClass(TestCase):</div><div>    def setup_class(self):</div><div>
       # setup codes</div><div><br></div><div>    def teardown_class(self):</div><div>       # teardown codes</div><div><br></div><div><br></div><div>Note: All this is nosetest extension, i.e. can only run under nosetest.</div>