<!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 11/11/2010 09:42, Gabriele Lanaro wrote:
    <blockquote
      cite="mid:AANLkTinwDqd6ptTewHt6aWtNwcQK5Vy6LoE_4JuoZE4a@mail.gmail.com"
      type="cite">I started a new "almost dummy" project to test the new
      functionalities of unittest2 but I'm encountering a lot of issues,
      I think because I'm not finding the best practices of python
      testing. I'm looking for suggestion on how to approach the
      development, here's my workflow:
      <div>
        <br>
      </div>
      <div>1) create a directory structure and a setup script:</div>
      <div><br>
      </div>
      <div>bashpy/</div>
      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;setup.cfg</div>
      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;README</div>
      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;bashpy/</div>
      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__init__.py</div>
      <div>
        &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;commands.py</div>
      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;tests/</div>
      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__init__.py</div>
      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;test_commands.py</div>
      <div><br>
      </div>
      <div>2) Write some functions in the bashpy.commands module, say
        `mkdir(src)` and `rm(src)`</div>
      <div><br>
      </div>
      <div>3) Write test classes in test_commands.py</div>
      <div><br>
      </div>
      <div>from bashpy.commands import mkdir,rm</div>
      <div>import unittest2 as unittest</div>
      <div><br>
      </div>
      <div>class TestRm(unittest.TestCase):</div>
      <div>&nbsp;&nbsp; &nbsp;def test1 ...</div>
      <div><br>
      </div>
      <div>class TestCp ....</div>
      <div><br>
      </div>
      <div>4) Run the tests</div>
      <div><br>
      </div>
      <div>from the root directory</div>
      <div><br>
      </div>
      <div>$ unit2 discover</div>
      <div>... correct output from the tests ...</div>
      <div>... oh! I failed TestRm.test1 !!!...</div>
      <div><br>
      </div>
      <div>5) Run a specific test to solve problems:</div>
      <div>$ unit2 bashpy.tests.test_commands.TestRm.test1</div>
      <div>ImportError: No module named bashpy</div>
      <div>
        <br>
      </div>
      <div>What I'm doing wrong? There's a similar linear workflow/best
        practices used to avoid import problems etc?</div>
    </blockquote>
    <br>
    Sorry for the late reply. If your package layout is as described
    then your tests aren't inside the bashpy package - they are
    alongside it. So the correct invocation for step 5 should be:<br>
    <br>
    $ unit2 tests.test_commands.TestRm.test1<br>
    <br>
    All the best,<br>
    <br>
    Michael Foord<br>
    <blockquote
      cite="mid:AANLkTinwDqd6ptTewHt6aWtNwcQK5Vy6LoE_4JuoZE4a@mail.gmail.com"
      type="cite">
      <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.voidspace.org.uk/">http://www.voidspace.org.uk/</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>