__init__.py in the project folder breaks nasal tests

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 within the project or its test directory. However, if I add an empty __init__.py to the project folder, I can no longer run nosetests from the test directory, which makes no sense to me.

 . |-- bar.py |-- __init__.py <-- new, empty file, ruining everything `-- test |-- __init__.py `-- test_bar.py 

Can someone explain to me what is going on here?

I read this topic extensively - through the nose documentation / reference pages and all over the Internet; but it seems very confusing to me how all this decides!

+4
source share
1 answer

It looks like your question has been answered here .

You have __init__.py in your top level directory. This makes the package. If you remove it, your media should work.

If you do not delete it, you will have to change the import to import dir.foo, where dir is the name of your directory.

+1
source

Source: https://habr.com/ru/post/1496383/


All Articles