python nose2: problem when multiple modules have the same name

131 Views Asked by At

I have a directory hierarchy containing tests, where I want to give the same name to test modules in different directories. For example,

/tests/xxx/test.py
/tests/yyy/test.py

nose2 discovery doesn't seem to handle this. I get an error as follows:

ImportError: 'test' module incorrectly imported from '/tests/xxx'. Expected '/tests/yyy'. Is this module globally installed?

Is there a way to handle this? It would make my life easier if I could give them the same name.

1

There are 1 best solutions below

2
On
import test
from importlib import reload
test = reload(test)

Try fitting this to your problem. Reloading the test module might work here.