在执行py.test以运行Python测试用例时,我面临以下错误:
Traceback (most recent call last):
File "/Users/mithha/.virtualenvs/uniq/lib/python3.7/site-packages/_pytest/config/__init__.py", line 372, in _getconftestmodules
return self._path2confmods[path]
KeyError: local('/Users/mithha/Documents/projects/DCS/dcs-ui/automation')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/mithha/.virtualenvs/uniq/lib/python3.7/site-packages/_pytest/config/__init__.py", line 403, in _importconftest
return self._conftestpath2mod[conftestpath]
KeyError: local('/Users/mithha/Documents/projects/DCS/dcs-ui/automation/conftest.py')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/xyz/.virtualenvs/uniq/lib/python3.7/site-packages/_pytest/config/__init__.py", line 409, in _importconftest
mod = conftestpath.pyimport()
File "/Users/xyz/.virtualenvs/uniq/lib/python3.7/site-packages/py/_path/local.py", line 668, in pyimport
__import__(modname)
File "/Users/xyz/.virtualenvs/uniq/lib/python3.7/site-packages/_pytest/assertion/rewrite.py", line 226, in load_module
py.builtin.exec_(co, mod.__dict__)
File "/Users/xyz/Documents/projects/DCS/dcs-ui/automation/conftest.py", line 13, in <module>
from uniq.common.exceptions import WtfException
ModuleNotFoundError: No module named 'uniq.common'
ERROR: could not load /Users/xyz/Documents/projects/DCS/dcs-ui/automation/conftest.py
找不到原因。较早的原因是找不到uniq
模块,但从pip
安装了该模块。现在,找不到uniq.common
模块。