You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:pytest-xdist识别Worker后无法收集指定目录测试用例

pytest-xdist 无法收集指定目录测试用例问题
  • 单独使用pytest执行tests/sqlalchemy-dialect-compliance目录下的测试用例无任何问题,该运行方式已稳定使用多年,但添加pytest-xdist后,无论调整何种配置,均无法从该目录收集到测试用例。
  • 当前在48核Linux主机的Docker容器中,尝试通过pytest结合pytest-xdist实现CPU并行测试。
  • pytest-xdist可正确识别Worker数量,但始终无法收集到任何测试用例,已尝试dist、tx、numprocesses等多种参数组合。

最近一次执行命令及输出如下:

nox > py.test -s -vvv --dist=each '--tx 4*popen//python=python3.11' --numprocesses=4 tests/sqlalchemy_dialect_compliance
=== test session starts =============================================================
platform linux -- Python 3.11.6, pytest-8.0.0, pluggy-1.4.0 -- /repo/github.com/googleapis/python-bigquery-sqlalchemy/.nox/compliance/bin/python
cachedir: .pytest_cache
rootdir: /repo/github.com/googleapis/python-bigquery-sqlalchemy
configfile: setup.cfg
plugins: xdist-3.5.0, rerunfailures-13.0
4 workers [0 items]     
scheduling tests via EachScheduling

=== no tests ran in 0.51s ============================================================
nox > Command py.test -s -vvv --dist=each '--tx 4*popen//python=python3.11' --numprocesses=4 tests/sqlalchemy_dialect_compliance failed with exit code 5 # No tests collected.
nox > Session compliance failed.

当设置numprocesses=auto时,工具可识别全部48核,但仍无测试用例被收集:

48 workers [0 items]

已在Python 3.11和3.12版本中进行测试,问题均存在。

内容的提问来源于stack exchange,提问作者E. Ducateme

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 08:47:37