[py-dev] Test directories for py.test
Tom Harris
beacybooks at bigpond.com
Fri Feb 23 02:39:43 CET 2007
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 <beacybooks at bigpond.com>
More information about the py-dev
mailing list