Reputation: 6048
project tree:
.
|-- bar.py
`-- test
|-- __init__.py
`-- test_bar.py
bar.py:
def dumb_true():
return True
tests/test_bar.py:
import bar
def test_bar_true():
assert bar.dumb_true()
I can run nosetests
from inside the project or its test directory. If I add an empty __init__.py
to the project folder, however, I can no longer run nosetests
from inside the test directory, which doesn't make any sense to me.
.
|-- bar.py
|-- __init__.py <-- new, empty file, ruining everything
`-- test
|-- __init__.py
`-- test_bar.py
Can anyone explain to me what's going on here?
I've read extensively on this topic - through nose documentation/man pages and all over the internet; but it looks very confusing to me how this all resolves!
Upvotes: 5
Views: 1811
Reputation: 62
Looks like your question was answered here.
You've got an
__init__.py
in your top level directory. That makes it a package. If you remove it, your nosetests should work.If you don't remove it, you'll have to change your import to import dir.foo, where dir is the name of your directory.
Upvotes: 3