我正在尝试通过编程调用向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。