Greetings,

I like to have my tests in a subdirectory for a project, so directory 
'foo' would have a subdirectory 'test'. The tests in 'test' should be 
able to load module foo.py in it's parent directory, with a 
sys.path.insert(0, '..'). That's the way I did it with unittest anyway. 
Example below fails unless I insert a '.' instead of '..' into sys.path.

file 'foo/foo.py':
    def a(): return 1

file 'foo/test/test_foo.py':
    import sys
    sys.path.insert(0, '..')
    import foo

    def test_1():
       assert foo.a() == 1

Now I'm quite happy to type import sys; sys.path.insert(0, '.') at the 
head of all my test files, but am I missing something?

-- 
Tom Harris BeacyBooks <[EMAIL PROTECTED]>

_______________________________________________
py-dev mailing list
py-dev@codespeak.net
http://codespeak.net/mailman/listinfo/py-dev

Reply via email to