mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-28 19:47:41 +08:00
test: 修复单测 warnings 并精确忽略上游弃用告警 (#5889)
This commit is contained in:
@@ -116,7 +116,7 @@ class NexusPhpSiteUserInfo(SiteParserBase):
|
|||||||
has_ucoin, self.bonus = self._parse_ucoin(html)
|
has_ucoin, self.bonus = self._parse_ucoin(html)
|
||||||
if has_ucoin:
|
if has_ucoin:
|
||||||
return
|
return
|
||||||
tmps = html.xpath('//a[contains(@href,"mybonus")]/text()') if html else None
|
tmps = html.xpath('//a[contains(@href,"mybonus")]/text()') if html is not None else None
|
||||||
if tmps:
|
if tmps:
|
||||||
bonus_text = str(tmps[0]).strip()
|
bonus_text = str(tmps[0]).strip()
|
||||||
bonus_match = re.search(r"([\d,.]+)", bonus_text)
|
bonus_match = re.search(r"([\d,.]+)", bonus_text)
|
||||||
|
|||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
[pytest]
|
||||||
|
# 仅对「无法在本仓修复根因」的已知上游/三方弃用告警做精确忽略,保持测试输出干净、
|
||||||
|
# 让本仓自身的新告警更醒目。本仓代码引发的告警一律不在此忽略,应在源码/用例处修复。
|
||||||
|
filterwarnings =
|
||||||
|
ignore:datetime.datetime.utcfromtimestamp\(\) is deprecated:DeprecationWarning
|
||||||
|
ignore:websockets.legacy is deprecated:DeprecationWarning
|
||||||
|
ignore:websockets.InvalidStatusCode is deprecated:DeprecationWarning
|
||||||
|
ignore:pkg_resources is deprecated as an API:DeprecationWarning
|
||||||
|
ignore:Deprecated call to .pkg_resources.declare_namespace:DeprecationWarning
|
||||||
|
ignore:'crypt' is deprecated:DeprecationWarning
|
||||||
|
ignore:'audioop' is deprecated:DeprecationWarning
|
||||||
@@ -453,7 +453,8 @@ class AgentImageSupportTest(unittest.TestCase):
|
|||||||
) as prepare_files, patch(
|
) as prepare_files, patch(
|
||||||
"app.chain.message.agent_manager.process_message", new_callable=AsyncMock
|
"app.chain.message.agent_manager.process_message", new_callable=AsyncMock
|
||||||
) as process_message, patch(
|
) as process_message, patch(
|
||||||
"app.chain.message.asyncio.run_coroutine_threadsafe"
|
"app.chain.message.asyncio.run_coroutine_threadsafe",
|
||||||
|
side_effect=lambda coro, _loop: coro.close(),
|
||||||
) as run_coroutine_threadsafe:
|
) as run_coroutine_threadsafe:
|
||||||
chain._handle_ai_message(
|
chain._handle_ai_message(
|
||||||
text="/ai 帮我看看这张图",
|
text="/ai 帮我看看这张图",
|
||||||
@@ -486,7 +487,7 @@ class AgentImageSupportTest(unittest.TestCase):
|
|||||||
"app.chain.message.agent_manager.process_message", new_callable=AsyncMock
|
"app.chain.message.agent_manager.process_message", new_callable=AsyncMock
|
||||||
) as process_message, patch(
|
) as process_message, patch(
|
||||||
"app.chain.message.asyncio.run_coroutine_threadsafe",
|
"app.chain.message.asyncio.run_coroutine_threadsafe",
|
||||||
side_effect=lambda coro, _loop: (coro.close(), Mock())[1],
|
side_effect=lambda coro, _loop: coro.close(),
|
||||||
):
|
):
|
||||||
chain._handle_ai_message(
|
chain._handle_ai_message(
|
||||||
text="帮我推荐一部电影",
|
text="帮我推荐一部电影",
|
||||||
|
|||||||
@@ -95,11 +95,16 @@ class TestTransferFailedRetryButtons(unittest.TestCase):
|
|||||||
errmsg="未识别到媒体信息",
|
errmsg="未识别到媒体信息",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _close_pending_coro(coro, *args, **kwargs):
|
||||||
|
"""关闭被调度的协程:测试中事件循环未运行,不关闭会残留 never-awaited 警告。"""
|
||||||
|
coro.close()
|
||||||
|
|
||||||
with patch.object(settings, "AI_AGENT_ENABLE", True):
|
with patch.object(settings, "AI_AGENT_ENABLE", True):
|
||||||
with patch(
|
with patch(
|
||||||
"app.chain.message.TransferHistoryOper"
|
"app.chain.message.TransferHistoryOper"
|
||||||
) as history_oper_cls, patch(
|
) as history_oper_cls, patch(
|
||||||
"app.chain.message.asyncio.run_coroutine_threadsafe"
|
"app.chain.message.asyncio.run_coroutine_threadsafe",
|
||||||
|
side_effect=_close_pending_coro,
|
||||||
) as run_task:
|
) as run_task:
|
||||||
history_oper_cls.return_value.get.return_value = history
|
history_oper_cls.return_value.get.return_value = history
|
||||||
with patch.object(chain, "post_message") as post_message:
|
with patch.object(chain, "post_message") as post_message:
|
||||||
|
|||||||
Reference in New Issue
Block a user