python - import error when run tests in submodule with nose -


we use git submodule share common module within our team.

each module has test cases in source folder, , ran nose.

i have project in structure:

/project_sample |__/project_sample |  |__ __init__.py |  |__ modulea.py |  |__/tests |  |  |__ __init__.py |  |  |__ modulea_tests.py |  |__/subpackage |     |__ __init__.py |     |__ moduleb.py |     |__/tests |        |__ __init__.py |        |__ moduleb_tests.py |__setup.py 

all of these init.py files empty.

the subpackage developed seperately , added project git submodule. want self-contained , , try share in different project. test case this:

moduleb_tests.py:  subpackage import moduleb  def test_funca():     moduleb.funca() 

the test pass when run nosetests subpackage's repo folder.

seems nose find init.py file in parent folder of subpackage (project_sample), when run nosetests project_sample's root directory, "importerror: no module named subpackage". passed when change first line to:

from project_sample.subpackage import moduleb 

but way makes subpackage not self-contained.

i tried way : adding subpackage sys.path or use -w option of nose, still exception.

my teammate run subpackage's test case seperately in pycharm , passed, think there should way make pass command line.

is there way resolve problem, or suggestion project structure?

this first question on so, suggestion appreciated.

if want subpackage self-contained, need treat such. means need put top-level, parallel project_sample instead of it.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -