Personal notes.
Python Nose Import Error - Stack Overflow
As you can see here
If you create __init__.py
in the execution directory and project directory,
That's the package you should refer to by name (maybe), so
current_dir (__init__.By having py**Package directory**become)
├ __init__.py
├─ lib
│ ├ __init__.py
│ └ bar.py
└─ test_dir
├ __init__.py
└ test_foo.py
If you have a directory structure like this,
$ cd current_dir
$ nosetests test_dir/test_foo.py
To pass through
test_foo.py
from lib import bar
from nose.tools import ok_
ok_(True, False)
Not
test_foo.py
from current_dir.lib import bar
from nose.tools import ok_
ok_(True, False)
I interpreted it as such a story that it would not pass unless it was done.
In python module import,
from .. import foo
from .dir import lib
It is written like this, but basically it is assumed that the directory at runtime is the root. (I want to use sys.path.append properly)
Recommended Posts