Reputation: 20530
Running PyTest
with files including ZODB
gives an odd problem: ZODB
can be imported, but its component FileSystem cannot.
import ZODB # That works fine.
import ZODB.FileStorage
ImportError: No module named FileStorage
On the other hand, running the same code from the Python interpreter runs fine.
This is version PyTest version 3.2.2, Python 2.7.13, and ZODB 5.2.4
There exists ZODB-5.2.4-py2.7.egg/ZODB/FileStorage/init.py, a ZODB.pth
pointing to the egg, and no other modules have issues; just any submodule of ZODB
. No odd permission errors. After an hour of experiments and exercising Google-Fu, I got nothing.
Well, I dropped this because it 'went away'. Now its back. This I know so far:
This shows up sometimes with PyTest, usually running a profiler. I haven't found a way around it. I don't know what causes it. I have some issues filed but haven't tracked it down.
File "/Users/cmerriam/p/platform/zzz/data/ZODB.py", line 41, in <module>
import ZODB.FileStorage # flake8: noqa
ImportError: No module named FileStorage
* Same issue from PyCharm or command line.
* No issue running normal code from PyCharm or command line.
* Once it starts to be an issue, it continues. Still don't know why.
* Once it goes away it stays away.
* My edit configuration has a warning "No Py.Test runner found for current configuration", though
/opt/zzz/bin/py.test is in path
* Seems to have occurred after a reboot.
* No reason, at all, to suspect FileStorage.
* This is in my ...../site-packages directory:
$ ls -l ZODB*
-rw-rw-r-- 1 cmerriam zzz 23 Oct 6 18:08 ZODB.pth
ZODB-5.2.4-py2.7.egg:
total 0
drwxr-xr-x 9 cmerriam zzz 306 Oct 6 18:08 EGG-INFO/
drwxr-xr-x 74 cmerriam zzz 2516 Oct 9 15:58 ZODB/
$ cd ZODB-5.2.4-py2.7.egg
$ tree
|-EGG-INFO
|-ZODB
|---FileStorage
|---__pycache__
|---scripts
|-----manual_tests
|-----tests
|---tests
There exists in the system a module named zzz.data.zodb.py. And I'm working on OS/X which is case preserving but not case sensitive. And yet I got a point with both "zzz.data.zodb" and "zzz.data.ZODB" in my sys.modules. And can we just make it an error to have two items align but for case yet?
I still would like nail down the edge cases of what happened.
Upvotes: 5
Views: 240
Reputation:
Try Something Like the following as discribed in another answer:
@A. Dickey -
from ZODB import FileStorage
In the comments discribes:
@nes -
Maybe module with same name located in sys.path. Try to see which files module usesimport ZODB; print(ZODB.__file__)
Upvotes: -1