wrestling with unittest paths..needs suggestions
Miki Tebeka
miki.tebeka at zoran.com
Thu Mar 11 19:44:23 EST 2004
Hello Vincent,
> path to main class... say:
>
> path = /home/workspace/src/foo
> There is a module Foo.py
> /home/workspace/src/foo/Foo.py
>
> My unittest is in:
> /home/workspace/src/test/foo
> so:
> /home/workspace/src/test/foo/FooTest.py
Usually the `test' directory is under the source directory
(/home/workspace/src/foo/test), this simplifies things.
> import os, sys
> testpath = os.path.abspath('/home/workspace/src/foo')
> sys.path.append(testpath)
>
> Well, it works but if I have to do that for every test module that I write..
> Very nasty..
Have a look at python's test suite for a good example
(/usr/lib/python23/test). There is one `test_support.py' module that
each test import. If you need you can fix the path in this module only.
If you use foo/test then just write `sys.path.append("..")' in
test_support.py
HTH.
Miki
More information about the Python-list
mailing list