每当我尝试在Docker容器中运行测试时,都会出现以下错误(主要是通过Jet-CLI for Codeship完成,尽管如果我使用docker-compose
和docker exec
命令来运行测试):
import file mismatch:
imported module 'affine.affine_test' has this __file__ attribute:
/home/ascourtas/Projects/xgl/test_harness/tests/regression/transforms/affine/affine_test.py
which is not the same as the test file we want to collect:
/test_harness/tests/regression/transforms/affine/affine_test.py
我用于运行测试的命令是:
PYTHONPATH=. timeout 600 pytest ./test_harness/tests/regression/transforms/affine/affine_test.py
我已经通过在我的.dockerignore中添加* .pyc和__pycache__
来删除.pyc文件和__pycache__
文件夹。我还向__init__.py
文件夹中添加了一个空白/affine
。
WORKDIR
设置为xgl
似乎容器正在使用测试的主机文件路径,而容器实际上应该使用容器文件路径。为什么会这样,我该如何解决呢?
编辑:已解决。原来是docker-compose只是被更新,以解决一些问题,而忽略了.dockerignore中的某些模式,而我一个月左右都没有更新-所以* .pyc和__pycache__
文件以及我以为我忽略的文件夹实际上已包含在内。