[Tutor] Modules and Test Suites

Eike Welk eike.welk at gmx.net
Tue Dec 29 16:47:55 CET 2009


Hello Stephen!

On Tuesday 29 December 2009, Stephen Nelson-Smith wrote:
> I do quite a lot of programming in Ruby.  When I do so, my code
> tends to have the following layout:
>
> /path/to/src/my_project
>
> Inside my_project:
>
> lib/
> test/
> my_project.rb
>

> b) If so - how can I do it in Python?

I think the test discovery programs "py.test" and "nose" do what you 
want. If I understand you correctly you want something that sets the 
right search path for library modules. 
http://codespeak.net/py/dist/test/
http://somethingaboutorange.com/mrl/projects/nose/0.11.1/

You could also tweak the environment variable "$PYTHONPATH" or the 
variable "sys.path".
See section 6.1.2:
http://docs.python.org/tutorial/modules.html

I use "py.test" and like it. But I keep tests and libraries in the 
same directory. I know however that "py.test" also supports separate 
directories for tests. 

Eike.


More information about the Tutor mailing list