I have a package and a test package. According to advice from Where do the Python unit tests go?, the tests should be in a different directory. The project's directory tree is as follows:
project\
kernel\
__init__.py
file1.py
file2.py
tests\
__init__.py
test1.py
test2.py
test3.py
I would like to import the kernel
package to the tests
package, because that is where file1.py
and file2.py
are being tested. Also, I would like to use one import
statement in the __init__.py
instead of importing kernel
again and again in each test.
I tried adding the following to the __init__.py
file in tests
and to test2.py
, test2.py
(together and separately), with no success (the first does no harm, the second gives a syntax error):
import kernel
import ../kernel
I'm using python2.6. From command line all the above happens. When I use Eclipse PyDev, everything magically works.