Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在Travis CI上的docker容器中运行Django测试_Python_Django_Docker_Docker Compose - Fatal编程技术网

Python 在Travis CI上的docker容器中运行Django测试

Python 在Travis CI上的docker容器中运行Django测试,python,django,docker,docker-compose,Python,Django,Docker,Docker Compose,[更新] 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`. =======================

[更新] 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时没有看到任何错误。有人能告诉我我怎么了吗

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"
特拉维斯·伊梅尔先生

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"

检查docker-compose.yml.-/应用程序:/api。希望对你有帮助。@DmitryThank你纠正了我愚蠢的错误!您使用的是pytest还是python manage.py测试?你的日志提到它是pytest。无论如何,新的错误是pytest没有找到任何测试(
收集了0项),因此没有什么可做的。也许可以尝试使用
ls
dir
查看是否可以查看测试?@QuentinPradet我使用pytest。我添加了一个简单的测试用例,然后没有出现错误。谢谢。查看docker-compose.yml。-/应用程序:/api。希望对你有帮助。@DmitryThank你纠正了我愚蠢的错误!您使用的是pytest还是python manage.py测试?你的日志提到它是pytest。无论如何,新的错误是pytest没有找到任何测试(
收集了0项),因此没有什么可做的。也许可以尝试使用
ls
dir
查看是否可以查看测试?@QuentinPradet我使用pytest。我添加了一个简单的测试用例,然后没有出现错误。谢谢