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

Poetry+Tox+Pytest指定测试环境执行异常问题求助

Poetry+Tox+Pytest 环境执行异常排查与解决

问题现象

  • 执行poetry run tox tests或poetry run tox py39-test时,所有测试环境会全部运行,无法仅指定单个环境执行
  • 指定py39-test环境时,pytest命令被直接跳过,未执行测试逻辑
  • 在poetry shell内执行tox <命令>,出现同样的异常情况
  • 初始配置下运行tox tests,日志显示tests和lint环境同时被执行;将envlist修改为{py39, py310}-{tests, lint}后,执行tox py39-tests时测试环境虽启动,但run-test命令被跳过

解决后的有效配置

[tox]
isolated_build = true

[testenv]
whitelist_externals = poetry
commands =
  poetry install -v
  poetry run pytest tests/
extras=
   tests

[testenv:lint]
commands =
   black -S src/
   flakeheaven lint src/
extras = 
   lint

内容的提问来源于stack exchange,提问作者flamusdiu

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.25 15:15:44