簡體   English   中英

Py.Test 以編程方式調用時找不到 pytest-parallel

[英]Py.Test Can't find pytest-parallel when invoked programmatically

我試圖通過編程調用向pytest發送並行參數,但似乎沒有像根本沒有安裝並行那樣識別它們,除了我知道那里是因為當我使用直接命令行調用運行py.test 時,包括相同的參數,它會找到它並成功運行。

錯誤:用法:invoke_pytest.py [options] [file_or_dir] [file_or_dir] [...] invoke_pytest.py:錯誤:無法識別的參數:--workers 1 --tests-per-worker 4

這是我的代碼:

import os
import sys
import pytest


pytest_args = [
    "tests/bdd",
    '--rootdir=tests/bdd',
    "--workers 1",
    "--tests-per-worker 4"
    # ...
]
result = pytest.main(pytest_args)
print(f"RESULT {result}")

雖然看起來無關,但我也在這個測試套件中使用了 py.test bdd 和 splinter。

弄清楚這是py.test 以編程方式解析參數的方式,與並行無關。 每個參數的值需要是列表的獨立位置!

# ...
pytest_args = [
    "tests/bdd",
    '--rootdir=tests/bdd',
    "--workers", "1",
    "--tests-per-worker", "4", # splitted argument and value
    # ...
]
result = pytest.main(pytest_args)
print(f"RESULT {result}")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM