Skip to content

test: 处理 #5877 review 反馈 + 提 PR 前跑全量门禁约定#5880

Merged
jxxghp merged 5 commits into
jxxghp:v2from
InfinityPacer:claude/test/review-followup
Jun 2, 2026
Merged

test: 处理 #5877 review 反馈 + 提 PR 前跑全量门禁约定#5880
jxxghp merged 5 commits into
jxxghp:v2from
InfinityPacer:claude/test/review-followup

Conversation

@InfinityPacer

Copy link
Copy Markdown
Contributor

背景

处理 gemini-code-assist 在 #5877 上的 review 反馈,并补齐「提 PR 前跑全量」的约定。

改动

1. 修 tests/test_tmdb_recognize.pysetUpModule 回滚(#5877 review)
上一版在任一 patcher.start() 失败时调用 tearDownModule() 回滚,但它会对所有 patcher(含尚未启动的)调用 stop(),触发 RuntimeError: can't stop patchers that haven't been started——既掩盖原始启动异常、又中断已启动 patcher 的清理。改为记录已成功启动的 patcher,异常时只回滚这些,再清空 _PATCHERS

2. tests/test_telegram.py 转 pytest 原生(#5877 review)
按本仓 docs/testing.md / AGENTS.md 的「改到即转」约定,将该文件从 unittest.TestCase 重构为 pytest 原生:setUp 改为 telegram fixture(with patch(...) 上下文自动停桩,实例化失败也不泄漏)、self.assertTrue(x) 改为 assert x、类方法改为函数式用例。测试数据与断言语义保持不变。

3. 「提 PR 前跑全量」约定
AGENTS.md### Testingdocs/testing.md 增加:提 PR 前先本地 python tests/run.py 确认全绿、零真实出站;test.yml 门禁在指向 v2 的 PR/push 上跑同样的全量。

验证

  • 全量(全新 requirements.in 环境):python tests/run.py = 942 passed / 1 skipped / 0 failed。
  • socket 探针:全量零真实出站

本 PR 为 Claude Code 协作提交

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the testing documentation in AGENTS.md and docs/testing.md to emphasize running local tests before opening a PR, refactors tests/test_telegram.py to use native pytest with a fixture, and improves patcher rollback safety in tests/test_tmdb_recognize.py. The review feedback correctly identifies that several test cases in tests/test_telegram.py use weak truthiness assertions on the dictionary returned by send_msg (which evaluates to True even when containing {"success": False}), and suggests explicitly asserting result.get("success") instead. Additionally, one test case was found to be missing an assertion entirely.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread tests/test_telegram.py Outdated
)

# 验证返回值
assert result

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

由于 Telegram.send_msg 在发送失败时会返回 {"success": False}(一个非空字典,在 Python 中布尔评估为 True),因此仅使用 assert result 无法捕获发送失败的情况。建议显式断言 result.get("success")

Suggested change
assert result
assert result and result.get("success")

Comment thread tests/test_telegram.py
result = telegram.send_msg(
title="MoviePilot助手",
text="好的,为您推荐一些近期热门的电视剧:\n\n* *怪奇物语 (Stranger Things)* - 2016年,TMDB评分8.6\n* *小丑回魂:欢迎来到德里镇* - 2025年,TMDB评分8.0\n* *维京传奇* - 2013年,TMDB评分8.1\n* *地狱客栈* - 2024年,TMDB评分8.7\n* *超人回来了* - 2013年,TMDB评分7.7\n\n还有一些经典剧集也一直很受欢迎:\n\n* *法律与秩序:特殊受害者* - 1999年,TMDB评分7.9\n* *实习医生格蕾* - 2005年,TMDB评分8.2\n* *邪恶力量* - 2005年,TMDB评分8.3\n* *菜鸟老警* - 2018年,TMDB评分8.5\n* *猎魔人* - 2019年,TMDB评分8.0\n* *海军罪案调查处* - 2003年,TMDB评分7.6\n* *塔尔萨之王* - 2022年,TMDB评分8.3\n* *武士生死斗* - 2025年,TMDB评分8.1\n* *嗜血法医* - 2006年,TMDB评分8.2\n* *辛普森一家* - 1989年,TMDB评分8.0\n* *无耻之徒* - 2011年,TMDB评分8.2\n* *绝命毒师* - 2008年,TMDB评分8.9\n* *法律与秩序* - 1990年,TMDB评分7.4\n* *权力的游戏* - 2011年,TMDB评分8.5\n\n您对哪部剧比较感兴趣,或者想了解更多信息呢?好的,为您推荐一些近期热门的电视剧:\n\n* *怪奇物语 (Stranger Things)* - 2016年,TMDB评分8.6\n* *小丑回魂:欢迎来到德里镇* - 2025年,TMDB评分8.0\n* *维京传奇* - 2013年,TMDB评分8.1\n* *地狱客栈* - 2024年,TMDB评分8.7\n* *超人回来了* - 2013年,TMDB评分7.7\n\n还有一些经典剧集也一直很受欢迎:\n\n* *法律与秩序:特殊受害者* - 1999年,TMDB评分7.9\n* *实习医生格蕾* - 2005年,TMDB评分8.2\n* *邪恶力量* - 2005年,TMDB评分8.3\n* *菜鸟老警* - 2018年,TMDB评分8.5\n* *猎魔人* - 2019年,TMDB评分8.0\n* *海军罪案调查处* - 2003年,TMDB评分7.6\n* *塔尔萨之王* - 2022年,TMDB评分8.3\n* *武士生死斗* - 2025年,TMDB评分8.1\n* *嗜血法医* - 2006年,TMDB评分8.2\n* *辛普森一家* - 1989年,TMDB评分8.0\n* *无耻之徒* - 2011年,TMDB评分8.2\n* *绝命毒师* - 2008年,TMDB评分8.9\n* *法律与秩序* - 1990年,TMDB评分7.4\n* *权力的游戏* - 2011年,TMDB评分8.5\n\n您对哪部剧比较感兴趣,或者想了解更多信息呢?好的,为您推荐一些近期热门的电视剧:\n\n* *怪奇物语 (Stranger Things)* - 2016年,TMDB评分8.6\n* *小丑回魂:欢迎来到德里镇* - 2025年,TMDB评分8.0\n* *维京传奇* - 2013年,TMDB评分8.1\n* *地狱客栈* - 2024年,TMDB评分8.7\n* *超人回来了* - 2013年,TMDB评分7.7\n\n还有一些经典剧集也一直很受欢迎:\n\n* *法律与秩序:特殊受害者* - 1999年,TMDB评分7.9\n* *实习医生格蕾* - 2005年,TMDB评分8.2\n* *邪恶力量* - 2005年,TMDB评分8.3\n* *菜鸟老警* - 2018年,TMDB评分8.5\n* *猎魔人* - 2019年,TMDB评分8.0\n* *海军罪案调查处* - 2003年,TMDB评分7.6\n* *塔尔萨之王* - 2022年,TMDB评分8.3\n* *武士生死斗* - 2025年,TMDB评分8.1\n* *嗜血法医* - 2006年,TMDB评分8.2\n* *辛普森一家* - 1989年,TMDB评分8.0\n* *无耻之徒* - 2011年,TMDB评分8.2\n* *绝命毒师* - 2008年,TMDB评分8.9\n* *法律与秩序* - 1990年,TMDB评分7.4\n* *权力的游戏* - 2011年,TMDB评分8.5\n\n您对哪部剧比较感兴趣,或者想了解更多信息呢?好的,为您推荐一些近期热门的电视剧:\n\n* *怪奇物语 (Stranger Things)* - 2016年,TMDB评分8.6\n* *小丑回魂:欢迎来到德里镇* - 2025年,TMDB评分8.0\n* *维京传奇* - 2013年,TMDB评分8.1\n* *地狱客栈* - 2024年,TMDB评分8.7\n* *超人回来了* - 2013年,TMDB评分7.7\n\n还有一些经典剧集也一直很受欢迎:\n\n* *法律与秩序:特殊受害者* - 1999年,TMDB评分7.9\n* *实习医生格蕾* - 2005年,TMDB评分8.2\n* *邪恶力量* - 2005年,TMDB评分8.3\n* *菜鸟老警* - 2018年,TMDB评分8.5\n* *猎魔人* - 2019年,TMDB评分8.0\n* *海军罪案调查处* - 2003年,TMDB评分7.6\n* *塔尔萨之王* - 2022年,TMDB评分8.3\n* *武士生死斗* - 2025年,TMDB评分8.1\n* *嗜血法医* - 2006年,TMDB评分8.2\n* *辛普森一家* - 1989年,TMDB评分8.0\n* *无耻之徒* - 2011年,TMDB评分8.2\n* *绝命毒师* - 2008年,TMDB评分8.9\n* *法律与秩序* - 1990年,TMDB评分7.4\n* *权力的游戏* - 2011年,TMDB评分8.5\n\n您对哪部剧比较感兴趣,或者想了解更多信息呢?好的,为您推荐一些近期热门的电视剧:\n\n* *怪奇物语 (Stranger Things)* - 2016年,TMDB评分8.6\n* *小丑回魂:欢迎来到德里镇* - 2025年,TMDB评分8.0\n* *维京传奇* - 2013年,TMDB评分8.1\n* *地狱客栈* - 2024年,TMDB评分8.7\n* *超人回来了* - 2013年,TMDB评分7.7\n\n还有一些经典剧集也一直很受欢迎:\n\n* *法律与秩序:特殊受害者* - 1999年,TMDB评分7.9\n* *实习医生格蕾* - 2005年,TMDB评分8.2\n* *邪恶力量* - 2005年,TMDB评分8.3\n* *菜鸟老警* - 2018年,TMDB评分8.5\n* *猎魔人* - 2019年,TMDB评分8.0\n* *海军罪案调查处* - 2003年,TMDB评分7.6\n* *塔尔萨之王* - 2022年,TMDB评分8.3\n* *武士生死斗* - 2025年,TMDB评分8.1\n* *嗜血法医* - 2006年,TMDB评分8.2\n* *辛普森一家* - 1989年,TMDB评分8.0\n* *无耻之徒* - 2011年,TMDB评分8.2\n* *绝命毒师* - 2008年,TMDB评分8.9\n* *法律与秩序* - 1990年,TMDB评分7.4\n* *权力的游戏* - 2011年,TMDB评分8.5\n\n您对哪部剧比较感兴趣,或者想了解更多信息呢?好的,为您推荐一些近期热门的电视剧:\n\n* *怪奇物语 (Stranger Things)* - 2016年,TMDB评分8.6\n* *小丑回魂:欢迎来到德里镇* - 2025年,TMDB评分8.0\n* *维京传奇* - 2013年,TMDB评分8.1\n* *地狱客栈* - 2024年,TMDB评分8.7\n* *超人回来了* - 2013年,TMDB评分7.7\n\n还有一些经典剧集也一直很受欢迎:\n\n* *法律与秩序:特殊受害者* - 1999年,TMDB评分7.9\n* *实习医生格蕾* - 2005年,TMDB评分8.2\n* *邪恶力量* - 2005年,TMDB评分8.3\n* *菜鸟老警* - 2018年,TMDB评分8.5\n* *猎魔人* - 2019年,TMDB评分8.0\n* *海军罪案调查处* - 2003年,TMDB评分7.6\n* *塔尔萨之王* - 2022年,TMDB评分8.3\n* *武士生死斗* - 2025年,TMDB评分8.1\n* *嗜血法医* - 2006年,TMDB评分8.2\n* *辛普森一家* - 1989年,TMDB评分8.0\n* *无耻之徒* - 2011年,TMDB评分8.2\n* *绝命毒师* - 2008年,TMDB评分8.9\n* *法律与秩序* - 1990年,TMDB评分7.4\n* *权力的游戏* - 2011年,TMDB评分8.5\n\n您对哪部剧比较感兴趣,或者想了解更多信息呢?好的,为您推荐一些近期热门的电视剧:\n\n* *怪奇物语 (Stranger Things)* - 2016年,TMDB评分8.6\n* *小丑回魂:欢迎来到德里镇* - 2025年,TMDB评分8.0\n* *维京传奇* - 2013年,TMDB评分8.1\n* *地狱客栈* - 2024年,TMDB评分8.7\n* *超人回来了* - 2013年,TMDB评分7.7\n\n还有一些经典剧集也一直很受欢迎:\n\n* *法律与秩序:特殊受害者* - 1999年,TMDB评分7.9\n* *实习医生格蕾* - 2005年,TMDB评分8.2\n* *邪恶力量* - 2005年,TMDB评分8.3\n* *菜鸟老警* - 2018年,TMDB评分8.5\n* *猎魔人* - 2019年,TMDB评分8.0\n* *海军罪案调查处* - 2003年,TMDB评分7.6\n* *塔尔萨之王* - 2022年,TMDB评分8.3\n* *武士生死斗* - 2025年,TMDB评分8.1\n* *嗜血法医* - 2006年,TMDB评分8.2\n* *辛普森一家* - 1989年,TMDB评分8.0\n* *无耻之徒* - 2011年,TMDB评分8.2\n* *绝命毒师* - 2008年,TMDB评分8.9\n* *法律与秩序* - 1990年,TMDB评分7.4\n* *权力的游戏* - 2011年,TMDB评分8.5\n\n您对哪部剧比较感兴趣,或者想了解更多信息呢?好的,为您推荐一些近期热门的电视剧:\n\n* *怪奇物语 (Stranger Things)* - 2016年,TMDB评分8.6\n* *小丑回魂:欢迎来到德里镇* - 2025年,TMDB评分8.0\n* *维京传奇* - 2013年,TMDB评分8.1\n* *地狱客栈* - 2024年,TMDB评分8.7\n* *超人回来了* - 2013年,TMDB评分7.7\n\n还有一些经典剧集也一直很受欢迎:\n\n* *法律与秩序:特殊受害者* - 1999年,TMDB评分7.9\n* *实习医生格蕾* - 2005年,TMDB评分8.2\n* *邪恶力量* - 2005年,TMDB评分8.3\n* *菜鸟老警* - 2018年,TMDB评分8.5\n* *猎魔人* - 2019年,TMDB评分8.0\n* *海军罪案调查处* - 2003年,TMDB评分7.6\n* *塔尔萨之王* - 2022年,TMDB评分8.3\n* *武士生死斗* - 2025年,TMDB评分8.1\n* *嗜血法医* - 2006年,TMDB评分8.2\n* *辛普森一家* - 1989年,TMDB评分8.0\n* *无耻之徒* - 2011年,TMDB评分8.2\n* *绝命毒师* - 2008年,TMDB评分8.9\n* *法律与秩序* - 1990年,TMDB评分7.4\n* *权力的游戏* - 2011年,TMDB评分8.5\n\n您对哪部剧比较感兴趣,或者想了解更多信息呢?好的,为您推荐一些近期热门的电视剧:\n\n* *怪奇物语 (Stranger Things)* - 2016年,TMDB评分8.6\n* *小丑回魂:欢迎来到德里镇* - 2025年,TMDB评分8.0\n* *维京传奇* - 2013年,TMDB评分8.1\n* *地狱客栈* - 2024年,TMDB评分8.7\n* *超人回来了* - 2013年,TMDB评分7.7\n\n还有一些经典剧集也一直很受欢迎:\n\n* *法律与秩序:特殊受害者* - 1999年,TMDB评分7.9\n* *实习医生格蕾* - 2005年,TMDB评分8.2\n* *邪恶力量* - 2005年,TMDB评分8.3\n* *菜鸟老警* - 2018年,TMDB评分8.5\n* *猎魔人* - 2019年,TMDB评分8.0\n* *海军罪案调查处* - 2003年,TMDB评分7.6\n* *塔尔萨之王* - 2022年,TMDB评分8.3\n* *武士生死斗* - 2025年,TMDB评分8.1\n* *嗜血法医* - 2006年,TMDB评分8.2\n* *辛普森一家* - 1989年,TMDB评分8.0\n* *无耻之徒* - 2011年,TMDB评分8.2\n* *绝命毒师* - 2008年,TMDB评分8.9\n* *法律与秩序* - 1990年,TMDB评分7.4\n* *权力的游戏* - 2011年,TMDB评分8.5\n\n您对哪部剧比较感兴趣,或者想了解更多信息呢?好的,为您推荐一些近期热门的电视剧:\n\n* *怪奇物语 (Stranger Things)* - 2016年,TMDB评分8.6\n* *小丑回魂:欢迎来到德里镇* - 2025年,TMDB评分8.0\n* *维京传奇* - 2013年,TMDB评分8.1\n* *地狱客栈* - 2024年,TMDB评分8.7\n* *超人回来了* - 2013年,TMDB评分7.7\n\n还有一些经典剧集也一直很受欢迎:\n\n* *法律与秩序:特殊受害者* - 1999年,TMDB评分7.9\n* *实习医生格蕾* - 2005年,TMDB评分8.2\n* *邪恶力量* - 2005年,TMDB评分8.3\n* *菜鸟老警* - 2018年,TMDB评分8.5\n* *猎魔人* - 2019年,TMDB评分8.0\n* *海军罪案调查处* - 2003年,TMDB评分7.6\n* *塔尔萨之王* - 2022年,TMDB评分8.3\n* *武士生死斗* - 2025年,TMDB评分8.1\n* *嗜血法医* - 2006年,TMDB评分8.2\n* *辛普森一家* - 1989年,TMDB评分8.0\n* *无耻之徒* - 2011年,TMDB评分8.2\n* *绝命毒师* - 2008年,TMDB评分8.9\n* *法律与秩序* - 1990年,TMDB评分7.4\n* *权力的游戏* - 2011年,TMDB评分8.5\n\n您对哪部剧比较感兴趣,或者想了解更多信息呢?好的,为您推荐一些近期热门的电视剧:\n\n* *怪奇物语 (Stranger Things)* - 2016年,TMDB评分8.6\n* *小丑回魂:欢迎来到德里镇* - 2025年,TMDB评分8.0\n* *维京传奇* - 2013年,TMDB评分8.1\n* *地狱客栈* - 2024年,TMDB评分8.7\n* *超人回来了* - 2013年,TMDB评分7.7\n\n还有一些经典剧集也一直很受欢迎:\n\n* *法律与秩序:特殊受害者* - 1999年,TMDB评分7.9\n* *实习医生格蕾* - 2005年,TMDB评分8.2\n* *邪恶力量* - 2005年,TMDB评分8.3\n* *菜鸟老警* - 2018年,TMDB评分8.5\n* *猎魔人* - 2019年,TMDB评分8.0\n* *海军罪案调查处* - 2003年,TMDB评分7.6\n* *塔尔萨之王* - 2022年,TMDB评分8.3\n* *武士生死斗* - 2025年,TMDB评分8.1\n* *嗜血法医* - 2006年,TMDB评分8.2\n* *辛普森一家* - 1989年,TMDB评分8.0\n* *无耻之徒* - 2011年,TMDB评分8.2\n* *绝命毒师* - 2008年,TMDB评分8.9\n* *法律与秩序* - 1990年,TMDB评分7.4\n* *权力的游戏* - 2011年,TMDB评分8.5\n\n您对哪部剧比较感兴趣,或者想了解更多信息呢?好的,为您推荐一些近期热门的电视剧:\n\n* *怪奇物语 (Stranger Things)* - 2016年,TMDB评分8.6\n* *小丑回魂:欢迎来到德里镇* - 2025年,TMDB评分8.0\n* *维京传奇* - 2013年,TMDB评分8.1\n* *地狱客栈* - 2024年,TMDB评分8.7\n* *超人回来了* - 2013年,TMDB评分7.7\n\n还有一些经典剧集也一直很受欢迎:\n\n* *法律与秩序:特殊受害者* - 1999年,TMDB评分7.9\n* *实习医生格蕾* - 2005年,TMDB评分8.2\n* *邪恶力量* - 2005年,TMDB评分8.3\n* *菜鸟老警* - 2018年,TMDB评分8.5\n* *猎魔人* - 2019年,TMDB评分8.0\n* *海军罪案调查处* - 2003年,TMDB评分7.6\n* *塔尔萨之王* - 2022年,TMDB评分8.3\n* *武士生死斗* - 2025年,TMDB评分8.1\n* *嗜血法医* - 2006年,TMDB评分8.2\n* *辛普森一家* - 1989年,TMDB评分8.0\n* *无耻之徒* - 2011年,TMDB评分8.2\n* *绝命毒师* - 2008年,TMDB评分8.9\n* *法律与秩序* - 1990年,TMDB评分7.4\n* *权力的游戏* - 2011年,TMDB评分8.5\n\n您对哪部剧比较感兴趣,或者想了解更多信息呢?",
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

此测试用例中缺少断言。由于 Telegram.send_msg 在发送失败时会返回 {"success": False},建议添加显式断言以确保发送成功。

Suggested change
)
)
assert result and result.get("success")

Comment thread tests/test_telegram.py Outdated
)

# 验证返回值
assert result

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

由于 Telegram.send_msg 在发送失败时会返回 {"success": False}(一个非空字典,在 Python 中布尔评估为 True),因此仅使用 assert result 无法捕获发送失败的情况。建议显式断言 result.get("success")

Suggested change
assert result
assert result and result.get("success")

Comment thread tests/test_telegram.py Outdated
)

# 验证返回值
assert result

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

由于 Telegram.send_msg 在发送失败时会返回 {"success": False}(一个非空字典,在 Python 中布尔评估为 True),因此仅使用 assert result 无法捕获发送失败的情况。建议显式断言 result.get("success")

Suggested change
assert result
assert result and result.get("success")

Comment thread tests/test_telegram.py Outdated
)

# 验证返回值
assert result

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

由于 Telegram.send_msg 在发送失败时会返回 {"success": False}(一个非空字典,在 Python 中布尔评估为 True),因此仅使用 assert result 无法捕获发送失败的情况。建议显式断言 result.get("success")

Suggested change
assert result
assert result and result.get("success")

@jxxghp jxxghp merged commit bc358fc into jxxghp:v2 Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants