带有addoption的Python3 xdist

时间:2018-05-07 09:30:55

标签: python-3.x pytest xdist

我想在分布式和子流程测试中使用自定义选项。 我有2个addoption --resources_dir和--output_dir。

尝试启动它:

python3 -m pytest -vs --junitxml=/tmp/result_alert_test.xml --resources_dir=test/resources --output_dir=/tmp/ -n auto test_*

错误消息:

Replacing crashed worker gw82
Cusage: -c [options] [file_or_dir] [file_or_dir] [...]
-c: error: the following arguments are required: --resources_dir, --output_dir
[gw83] node down: Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/execnet/gateway_base.py", line 1072, in executetask

当我在一个进程中运行测试时没有xdist(-n auto),它正在工作。

python3 -m pytest -vs --junitxml=/tmp/result_alert_test.xml --resources_dir=test/resources --output_dir=/tmp/ test_*

如果我从最后一个命令开始。它的工作与单一过程。没有错误。

=============================== test session starts ===============================
platform linux -- Python 3.5.2, pytest-3.5.0, py-1.5.3, pluggy-0.6.0 -- /usr/bin/python3
cachedir: ../../../../../.pytest_cache
rootdir: /, inifile:
plugins: xdist-1.22.2, forked-0.2
collected 115 items  

1 个答案:

答案 0 :(得分:1)

https://github.com/pytest-dev/pytest/issues/2026

没有修复此错误。 我用过环境。

python3 -m pytest -vsx --full-trace --junitxml=${TEST_REPORT_DIR}/result_alert_test.xml --tx=popen//env:TEST_DIR=${TESTS_ROOT} --tx=popen//env:TEST_OUTPUT_DIR=${TEST_OUTPUT_DIR} -n auto -vs test_*
相关问题