【发布时间】:2018-05-07 09:30:55
【问题描述】:
我想在分布式和子流程测试中使用自定义选项。 我有 2 个附加选项 --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
【问题讨论】:
-
您介意分享您的自定义
pytest_addoption代码的代码吗?最有可能是您的论点中的“_”导致了麻烦。尝试将命令行选项传递为--resouece-dir和--output-dir。您修改后的命令将是python3 -m pytest -vs --junitxml=/tmp/result_alert_test.xml --resources-dir=test/resources --output-dir=/tmp/ -n auto test_*
标签: python-3.x pytest xdist