Skip to content

[CI] pytest 收集冲突:test_system_router.py 同名导致所有后端 PR 的 CI 必红 #899

Description

@Alex-Fleet

问题现象

所有改动 backend/ 的 PR 的 Backend unit tests CI 必然失败(#896#897 均命中)。

根因

pytest -m unit收集阶段报错中断,任何测试都未执行:

  • backend/test/unit/routers/test_system_router.py
  • backend/test/integration/api/test_system_router.py

两个文件 basename 同为 test_system_router,pytest 按文件名建模块名导致同名冲突(collection error):

ERROR test/integration/api/test_system_router.py
Interrupted: 1 error during collection
HINT: ... use a unique basename for your test file modules

复现cd backend && uv run pytest -m unit -q(本地与 CI 一致)

影响

修复建议

重命名 backend/test/integration/api/test_system_router.pytest_system_router_api.py,消除同名冲突。该文件带 pytest.mark.integration,仅需 docker 环境运行,重命名无逻辑影响。

备选:CI 命令限定 pytest -m unit test/unit(与 Makefile 行为不一致,且治标不治本,后续新增同名文件还会复发)。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions