如何修复“pytest:错误:无法识别的参数:-n”

Dha*_*kar 13 pytest pytest-xdist

您好,我正在尝试在天蓝色管道上并行运行我的测试(pytest-xdist)。到目前为止,测试运行得非常好。突然,pytest 抛出一个奇怪的错误,提示“无法识别的参数”。

文件名:integration_test.py 使用的命令:pytest -n 5 --tb=shortintegration_test.py -v -s --> 并行运行 5 个测试测试总数:57 版本:pytest==6.2.5 pytest- xdist==2.3.0 甚至尝试过这两个模块的最新版本。

错误:错误:用法:pytest [选项] [file_or_dir] [file_or_dir] [...] pytest:错误:无法识别的参数:-nintegration_test.py

我怎样才能克服这个错误?

Bow*_*SFT 10

您遇到的就是这个错误:

Error : ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...] pytest: error: unrecognized arguments: -n integration_test.py  
  initfile: None
  rootdir: C:\test
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

正如 hoefling 提到的,解决方案是安装 pytest-xdist:

pip install pytest-xdist