【问题标题】:Python3 xdist with addoption带有附加选项的 Python3 xdist
【发布时间】: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


【解决方案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_*

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多