[已更新] 似乎pytest是通过按注释中所述更新docker-compose.yaml来运行的,但构建未成功完成。怎么了?
WARNING: Image for service app was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
============================= test session starts ==============================
platform linux -- Python 3.7.5, pytest-5.2.2, py-1.8.0, pluggy-0.13.0
rootdir: /api
plugins: django-3.6.0
collected 0 items
============================ no tests ran in 0.01s =============================
The command "docker-compose run --rm app sh -c "pytest && flake8"" exited with 5.
Done. Your build exited with 1.
我想在Travis的Docker容器中运行Django测试。但是,我看到了错误
python:无法打开文件'manage.py':[Errno 2]没有这样的文件或目录 命令“ docker-compose run --rm app sh -c“ python manage.py test && flake8””退出2。
我感到有点奇怪,因为在使用docker-compose.yml尝试docker-compose up -d
时没有看到任何错误。有人可以让我知道我怎么了吗?
Dockerfile
FROM python:3.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /api
WORKDIR /api
ADD . /api/
RUN pip3 install --upgrade pip
RUN pip3 install pipenv
RUN pipenv install --skip-lock --system --dev
docker-compose.yml
version: '3'
services:
app:
build:
context: .
ports:
- "8000:8000"
volumes:
- ./app:/api
command: >
sh -c "python manage.py runserver 0.0.0.0:8000"
.travis.yml
language: python
python:
- "3.7"
services:
- docker
before_script: pip install docker-compose
script:
- docker-compose run --rm app sh -c "python manage.py test && flake8"