m0169 2023-06-06 12:06 采纳率: 50%
浏览 30

关于#python#的问题:使用pytest-xdist运行测试用例,执行命令 pytest -n 2,执行时只有一个进程在执行

使用pytest-xdist运行测试用例,执行命令 pytest -n 2,执行时只有一个进程在执行。Python的版本:3.9.6,pytest-xdist插件版本:2.5.0。求解答

执行命令
PS D:\daima-tool> pytest -n 2 .\test_case.py

执行的结果
platform win32 -- Python 3.9.6, pytest-7.0.1, pluggy-1.0.0 -- D:\Python\python39.exe
cachedir: .pytest_cache
metadata: {'Python': '3.9.6', 'Platform': 'Windows-10-10.0.19045-SP0', 'Packages': {'pytest': '7.0.1', 'py': '1.11.0', 'pluggy': '1.0.0'}, 'Plugins': {'allure-pytest'
: '2.9.45', 'forked': '1.4.0', 'html': '3.1.1', 'metadata': '2.0.1', 'ordering': '0.6', 'rerunfailures': '10.2', 'xdist': '2.5.0'}, 'JAVA_HOME': 'D:\\java'}
rootdir: D:\daima-tool\controller-test, configfile: pytest.ini
plugins: allure-pytest-2.9.45, forked-1.4.0, html-3.1.1, metadata-2.0.1, ordering-0.6, rerunfailures-10.2, xdist-2.5.0
[gw0] win32 Python 3.9.6 cwd: D:\daima-tool\controller-test
[gw1] win32 Python 3.9.6 cwd: D:\daima-tool\controller-test
[gw0] Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)]
[gw1] Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)]
gw0 [2551] / gw1 [2551]
scheduling tests via LoadScopeScheduling

test_case.py::Test::test_voice[case0]
[gw0] [  0%] FAILED test_case.py::Test::test_voice[case0]
test_case.py::Test::test_voice[case1]
[gw0] [  0%] PASSED test_case.py::Test::test_voice[case1]
test_case.py::Test::test_voice[case2]
[gw0] [  0%] FAILED test_case.py::Test::test_voice[case2]
test_case.py::Test::test_voice[case3]
[gw0] [  0%] PASSED test_case.py::Test::test_voice[case3]
test_case.py::Test::test_voice[case4]
[gw0] [  0%] PASSED test_case.py::Test::test_voice[case4]
test_case.py::Test::test_voice[case5]
[gw0] [  0%] PASSED test_case.py::Test::test_voice[case5]
test_case.py::Test::test_voice[case6]
[gw0] [  0%] PASSED test_case.py::Test::test_voice[case6]
  • 写回答

2条回答 默认 最新

  • 瞬间动力 2023-06-06 12:48
    关注

    可能是因为您的运行环境中有多个Python解释器,而pytest-xdist默认只在主解释器上运行测试用例,导致无法启动其他进程。
    你可以尝试使用Python解释器来做下指定,可以参考:

    pytest -n 2 --python=python3 test_case.py
    

    其中,--python选项指定要使用的Python解释器,您需要将其替换为您实际的Python解释器名称或路径。另外,您还可以尝试使用-vv选项来查看更详细的运行过程和输出信息。
    如果仍然无法解决问题,您可以尝试升级pytest-xdist插件版本或者重新安装该插件,以确保它与您的Python解释器版本兼容。

    还有问题的话再问我好了

    评论

报告相同问题?

问题事件

  • 创建了问题 6月6日

悬赏问题

  • ¥15 is not in the mmseg::model registry。报错,模型注册表找不到自定义模块。
  • ¥15 安装quartus II18.1时弹出此error,怎么解决?
  • ¥15 keil官网下载psn序列号在哪
  • ¥15 想用adb命令做一个通话软件,播放录音
  • ¥30 Pytorch深度学习服务器跑不通问题解决?
  • ¥15 部分客户订单定位有误的问题
  • ¥15 如何在maya程序中利用python编写领子和褶裥的模型的方法
  • ¥15 Bug traq 数据包 大概什么价
  • ¥15 在anaconda上pytorch和paddle paddle下载报错
  • ¥25 自动填写QQ腾讯文档收集表