Import errors into subsystems for ZODB, but only for Py.Test

Running PyTest with files, including ZODB , presents an odd problem: ZODB can be imported, but its FileSystem component 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 is fine.

This is PyTest version 3.2.2, Python 2.7.13, and ZODB 5.2.4 There is ZODB-5.2.4-py2.7.egg/ZODB/FileStorage/init.py, a ZODB.pth pointing to an egg, and no other modules have no problems; just any submodule in ZODB . Odd permission errors. After an hour of experimenting and practicing Google-Fu, I got nothing.

Any workaround would be appreciated.

Well, I refused it because he "left." Now his back. I still know this:

  • This sometimes appears with PyTest, usually with the launch of the profiler. I did not find a way around him. I do not know what causes it. I have some problems, but they did not track it.

     File "/Users/cmerriam/p/platform/zzz/data/ZODB.py", line 41, in <module> import ZODB.FileStorage # flake8: noqa ImportError: No module named FileStorage 

What I see:

  * 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 

Things that didn't work:

  • Uninstall and reinstall PyTest
  • Restart pycharm validation environment
  • Right click in the project "clean compiled python files"
  • First run a regular python test.
  • Running pytest from the command line in different directories
  • Reboot again
  • Pip Install pytest-runner
  • Install new zzz version
  • Run 'python setup.py install'
  • Moving ZODB-5.2.4-py2.7.egg / EGG-INFO / to ZODB-5.2.4-py2.7.egg-info

Yeah! CLUE!

There is a module in the system called zzz.data.zodb.py. And I'm working on OS / X, which is persistent but not case sensitive. And yet I got a point with "zzz.data.zodb" and "zzz.data.ZODB" in my sys.modules. And can we just make it a mistake to align the two elements, but for the case?

I would still like a nail in extreme cases of what happened.

+5
source share
2 answers

Have you tried the following:

 from ZODB import FileStorage 
0
source

Try something like the following, as described in another answer:

@A. Dickey -

from ZODB import FileStorage

The comments say:

@nes -
Perhaps a module with the same name is located in sys.path. Try to see which file module uses import ZODB; print(ZODB.__file__) import ZODB; print(ZODB.__file__)

-1
source

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


All Articles