[Tutor] import and unittest

Kent Johnson kent37 at tds.net
Tue Jan 16 16:29:02 CET 2007

Thomas Coopman wrote:
> Hi,
> the documentation of pyunit 
> say that it is good to place the unittest in a seperate module.
> I wondered if it was possible to do something like this:
> src/
>     -a_module/
>         -sub_module/
> test/
>     -a_module/
>         -sub_module/
> So the test are in a complete different directory than the code and the 
> test dir is a complete copy
> of the src dir but with unittest instead of code.
> I have something like this but I don't know how to organize the imports 
> in the tests and I don't know
> if this is a good idea.  What do you think?

I have tried this but I think it is more trouble than it is worth having 
an extra set of directories to navigate. I put the tests in the same 
directory as the module under test. The tests for module.py are in 
moduletest.py. By putting 'test' at the end, the tests are listed next 
to the module under test in directory listings, which I like.

I use ant (a Java tool) for most of my packaging and it is easy to 
filter files by name so I don't need an extra directory for that.


More information about the Tutor mailing list