0

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.

Ziffusion
  • 8,779
  • 4
  • 29
  • 57

1 Answers1

0
import test
from importlib import reload
test = reload(test)

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

ycx
  • 3,155
  • 3
  • 14
  • 26
  • This is not how things are setup. In the "discovery" mode, nose2 traverses the directory structure, and loads the test modules it finds automatically. There isn't an opportunity to explicitly load or reload the module like this. – Ziffusion Feb 28 '19 at 21:07
  • @Ziffusion I see, then you will have to go through line by line of the stacktrace to figure out where in the source code of nose2 is doing that. Then change the source code over there with an if condition to accomodate for your case. – ycx Mar 01 '19 at 04:58