Существует стандартный вывод из `py.test`, но нет стандартного выхода из` python -m pytest` - PullRequest
0 голосов
/ 14 февраля 2019

Файл Docker

ARG SOURCE_IMAGE
FROM ${SOURCE_IMAGE}

# How to Mount a volume and run Pytest from
# https://stackoverflow.com/questions/35322452/is-there-a-way-to-sandbox-test-execution-with-pytest-especially-filesystem-acce

RUN adduser --disabled-password --gecos "" --uid 7357 pytest
COPY ./ /home/pytest
WORKDIR /home/pytest

# setup the python and pytest environments
RUN pip install --upgrade pip setuptools pytest
RUN pip install --upgrade -r requirements.txt
RUN pip install --upgrade -r requirements_dev.txt
RUN python setup.py develop

# setup entry point
USER pytest
ENTRYPOINT ["/bin/bash", "-l", "-c"]

Запуск вызовов без вывода

docker run --rm --mount source=example,target=/home/pytest example_pytest  pytest
============================= test session starts ==============================
platform linux -- Python 3.7.2, pytest-4.2.1, py-1.7.0, pluggy-0.8.1
benchmark: 3.2.2 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision$
10 warmup=False warmup_iterations=100000)
rootdir: /home/pytest, inifile: setup.cfg
plugins: cov-2.6.1, benchmark-3.2.2
collected 1 item

tests/test_example.py .                                                  [100%]

=========================== 1 passed in 0.05 seconds ===========================

Запуск вызовов без вывода

docker run -a stdin -a stdout -a stderr --rm --mount source=example,target=/home/pytest example_pytest  python -m mypy --ignore-missing
-imports --disallow-untyped-defs example
docker run -a stdin -a stdout -a stderr --rm --mount source=example,target=/home/pytest example_pytest python --version
docker run -a stdin -a stdout -a stderr --rm --mount source=example,target=/home/pytest example_pytest python -m pytest

1 Ответ

0 голосов
/ 14 февраля 2019

Решение

Я закончил тем, что удалил часть ENTRYPOINT ["/bin/bash", "-l", "-c"] Dockerfile, и мне удалось увидеть выходные данные команд run.

Вызовы с рабочим выходом

docker run -a stdin -a stdout -a stderr --rm --mount source=example,target=/home/pytest example_pytest  python -m mypy --ignore-missing
-imports --disallow-untyped-defs example
docker run -a stdin -a stdout -a stderr --rm --mount source=example,target=/home/pytest example_pytest python --version
Python 3.7.2
docker run -a stdin -a stdout -a stderr --rm --mount source=example,target=/home/pytest example_pytest python -m pytest
============================= test session starts ==============================
platform linux -- Python 3.7.2, pytest-4.2.1, py-1.7.0, pluggy-0.8.1
benchmark: 3.2.2 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=
10 warmup=False warmup_iterations=100000)
rootdir: /home/pytest, inifile: setup.cfg
plugins: cov-2.6.1, benchmark-3.2.2
collected 1 item

tests/test_example.py .                                                  [100%]

=========================== 1 passed in 0.05 seconds ===========================
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...