【发布时间】:2017-10-19 10:33:34
【问题描述】:
当我在本地运行测试时,它工作正常,但是在创建 docker 并在容器内运行后,我遇到了错误。
/usr/local/lib/python3.5/site-packages/_pytest/config.py:325: in _getconftestmodules
return self._path2confmods[path]
E KeyError: local('/apis/db/tests')
During handling of the above exception, another exception occurred:
/usr/local/lib/python3.5/site-packages/_pytest/config.py:356: in _importconftest
return self._conftestpath2mod[conftestpath]
E KeyError: local('/apis/db/tests/conftest.py')
During handling of the above exception, another exception occurred:
/usr/local/lib/python3.5/site-packages/_pytest/config.py:362: in _importconftest
mod = conftestpath.pyimport()
/usr/local/lib/python3.5/site-packages/py/_path/local.py:680: in pyimport
raise self.ImportMismatchError(modname, modfile, self)
_pytest.config.ConftestImportFailure: ImportMismatchError('conftest', '/projects/my_project/db/tests/conftest.py', local('/apis/db/tests/conftest.py'))
/apis - 它是 Dockerfile 中的 WORKDIR。
【问题讨论】:
-
您可能在 python 导入路径或符号链接或其他方面存在一些问题。什么是
/projects/my_project,什么是/apis?它们是目录还是符号链接?它们之间有什么关系? -
@MarSoft /projects 在主目录中,/apis 在 docker 的主目录中,顺便说一句,我已经解决了这个问题。谢谢!