From bf788ff72a3a324ddc881e0c22abc17366557738 Mon Sep 17 00:00:00 2001 From: Azide Date: Sun, 16 Jul 2023 17:09:26 +0800 Subject: [PATCH] =?UTF-8?q?:rotating=5Flight:=20=E7=A7=BB=E9=99=A4noqa:=20?= =?UTF-8?q?E501?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit :lipstick: auto fix by pre-commit hooks --- nonebot_bison/__init__.py | 2 +- nonebot_bison/admin_page/__init__.py | 6 ++---- nonebot_bison/config/db_config.py | 4 +--- nonebot_bison/config/db_migration.py | 3 ++- nonebot_bison/platform/arknights.py | 8 ++++++-- nonebot_bison/platform/bilibili.py | 2 +- nonebot_bison/platform/platform.py | 16 ++++----------- nonebot_bison/platform/weibo.py | 14 ++++++++----- nonebot_bison/plugin_config.py | 4 +--- nonebot_bison/scheduler/scheduler.py | 4 +--- nonebot_bison/sub_manager/add_sub.py | 6 ++++-- nonebot_bison/utils/context.py | 4 +--- pyproject.toml | 3 ++- tests/platforms/test_bilibili.py | 30 ++++++++++++++++++++++------ tests/platforms/test_platform.py | 4 +--- tests/platforms/test_weibo.py | 12 ++++++++++- tests/sub_manager/test_abort.py | 5 ++++- tests/sub_manager/test_query_del.py | 5 ++++- tests/test_context.py | 5 ++++- tests/test_custom_post.py | 5 ++++- tests/test_render.py | 13 +++++------- tests/utils.py | 9 ++++++--- 22 files changed, 98 insertions(+), 66 deletions(-) diff --git a/nonebot_bison/__init__.py b/nonebot_bison/__init__.py index 46dde3f..32ea8a2 100644 --- a/nonebot_bison/__init__.py +++ b/nonebot_bison/__init__.py @@ -16,7 +16,7 @@ __help__plugin__name__ = "nonebot_bison" __usage__ = ( "本bot可以提供b站、微博等社交媒体的消息订阅,详情请查看本bot文档," f"或者{'at本bot' if plugin_config.bison_to_me else '' }发送“添加订阅”订阅第一个帐号," - f"发送“查询订阅”或“删除订阅”管理订阅" + "发送“查询订阅”或“删除订阅”管理订阅" ) __supported_adapters__ = nonebot_plugin_saa.__plugin_meta__.supported_adapters diff --git a/nonebot_bison/admin_page/__init__.py b/nonebot_bison/admin_page/__init__.py index 661c57e..b63609b 100644 --- a/nonebot_bison/admin_page/__init__.py +++ b/nonebot_bison/admin_page/__init__.py @@ -57,9 +57,7 @@ def init_fastapi(): port = driver.config.port if host in ["0.0.0.0", "127.0.0.1"]: host = "localhost" - logger.opt(colors=True).info( - f"Nonebot Bison frontend will be running at: " f"http://{host}:{port}/bison" - ) + logger.opt(colors=True).info(f"Nonebot Bison frontend will be running at: http://{host}:{port}/bison") logger.opt(colors=True).info("该页面不能被直接访问,请私聊bot 后台管理 以获取可访问地址") @@ -72,7 +70,7 @@ def register_get_token_handler(): await get_token.finish(f"请访问: {plugin_config.bison_outer_url}auth/{token}") get_token.__help__name__ = "获取后台管理地址" # type: ignore - get_token.__help__info__ = "获取管理bot后台的地址,该地址会" "在一段时间过后过期,请不要泄漏该地址" # type: ignore + get_token.__help__info__ = "获取管理bot后台的地址,该地址会在一段时间过后过期,请不要泄漏该地址" # type: ignore def check_driver_is_fastapi() -> bool: diff --git a/nonebot_bison/config/db_config.py b/nonebot_bison/config/db_config.py index ef6cc6b..5140775 100644 --- a/nonebot_bison/config/db_config.py +++ b/nonebot_bison/config/db_config.py @@ -52,9 +52,7 @@ class DBConfig: if not db_user: db_user = User(user_target=user.dict()) session.add(db_user) - db_target_stmt = ( - select(Target).where(Target.platform_name == platform_name).where(Target.target == target) - ) + db_target_stmt = select(Target).where(Target.platform_name == platform_name).where(Target.target == target) db_target: Target | None = await session.scalar(db_target_stmt) if not db_target: db_target = Target(target=target, platform_name=platform_name, target_name=target_name) diff --git a/nonebot_bison/config/db_migration.py b/nonebot_bison/config/db_migration.py index 08d3117..d9775ff 100644 --- a/nonebot_bison/config/db_migration.py +++ b/nonebot_bison/config/db_migration.py @@ -32,7 +32,8 @@ async def data_migrate(): if key in user_sub_set: # a user subscribe a target twice logger.error( - f"用户 {user['user_type']}-{user['user']} 订阅了 {platform_name}-{target_name} 两次,随机采用了一个订阅" # noqa: E501 + f"用户 {user['user_type']}-{user['user']} 订阅了 {platform_name}-{target_name} 两次," + "随机采用了一个订阅", ) continue user_sub_set.add(key) diff --git a/nonebot_bison/platform/arknights.py b/nonebot_bison/platform/arknights.py index 00f3fbd..4a5a6b4 100644 --- a/nonebot_bison/platform/arknights.py +++ b/nonebot_bison/platform/arknights.py @@ -113,9 +113,13 @@ class AkVersion(StatusChange): def compare_status(self, _, old_status, new_status): res = [] if old_status.get("preAnnounceType") == 2 and new_status.get("preAnnounceType") == 0: - res.append(Post("arknights", text="登录界面维护公告上线(大概是开始维护了)", target_name="明日方舟更新信息")) # noqa: E501 + res.append( + Post("arknights", text="登录界面维护公告上线(大概是开始维护了)", target_name="明日方舟更新信息") + ) elif old_status.get("preAnnounceType") == 0 and new_status.get("preAnnounceType") == 2: - res.append(Post("arknights", text="登录界面维护公告下线(大概是开服了,冲!)", target_name="明日方舟更新信息")) # noqa: E501 + res.append( + Post("arknights", text="登录界面维护公告下线(大概是开服了,冲!)", target_name="明日方舟更新信息") + ) if old_status.get("clientVersion") != new_status.get("clientVersion"): res.append(Post("arknights", text="游戏本体更新(大更新)", target_name="明日方舟更新信息")) if old_status.get("resVersion") != new_status.get("resVersion"): diff --git a/nonebot_bison/platform/bilibili.py b/nonebot_bison/platform/bilibili.py index c81b0f1..d03dfa6 100644 --- a/nonebot_bison/platform/bilibili.py +++ b/nonebot_bison/platform/bilibili.py @@ -54,7 +54,7 @@ class Bilibili(NewMessage): 2: "专栏文章", 3: "视频", 4: "纯文字", - 5: "转发" + 5: "转发", # 5: "短视频" } platform_name = "bilibili" diff --git a/nonebot_bison/platform/platform.py b/nonebot_bison/platform/platform.py index 9ec9073..5dfbf89 100644 --- a/nonebot_bison/platform/platform.py +++ b/nonebot_bison/platform/platform.py @@ -82,9 +82,7 @@ class Platform(metaclass=PlatformABCMeta, base=True): ... @abstractmethod - async def fetch_new_post( - self, target: Target, users: list[UserSubInfo] - ) -> list[tuple[PlatformTarget, list[Post]]]: + async def fetch_new_post(self, target: Target, users: list[UserSubInfo]) -> list[tuple[PlatformTarget, list[Post]]]: ... async def do_fetch_new_post( @@ -300,9 +298,7 @@ class NewMessage(MessageProcess, abstract=True): self.set_stored_data(target, store) return res - async def fetch_new_post( - self, target: Target, users: list[UserSubInfo] - ) -> list[tuple[PlatformTarget, list[Post]]]: + async def fetch_new_post(self, target: Target, users: list[UserSubInfo]) -> list[tuple[PlatformTarget, list[Post]]]: post_list = await self.get_sub_list(target) new_posts = await self.filter_common_with_diff(target, post_list) if not new_posts: @@ -339,9 +335,7 @@ class StatusChange(Platform, abstract=True): async def parse(self, raw_post: RawPost) -> Post: ... - async def fetch_new_post( - self, target: Target, users: list[UserSubInfo] - ) -> list[tuple[PlatformTarget, list[Post]]]: + async def fetch_new_post(self, target: Target, users: list[UserSubInfo]) -> list[tuple[PlatformTarget, list[Post]]]: try: new_status = await self.get_status(target) except self.FetchError as err: @@ -367,9 +361,7 @@ class StatusChange(Platform, abstract=True): class SimplePost(MessageProcess, abstract=True): "Fetch a list of messages, dispatch it to different users" - async def fetch_new_post( - self, target: Target, users: list[UserSubInfo] - ) -> list[tuple[PlatformTarget, list[Post]]]: + async def fetch_new_post(self, target: Target, users: list[UserSubInfo]) -> list[tuple[PlatformTarget, list[Post]]]: new_posts = await self.get_sub_list(target) if not new_posts: return [] diff --git a/nonebot_bison/platform/weibo.py b/nonebot_bison/platform/weibo.py index e8d4197..be09d95 100644 --- a/nonebot_bison/platform/weibo.py +++ b/nonebot_bison/platform/weibo.py @@ -112,8 +112,10 @@ class Weibo(NewMessage): async def parse(self, raw_post: RawPost) -> Post: header = { - "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng," - "*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", + "accept": ( + "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng," + "*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" + ), "accept-language": "zh-CN,zh;q=0.9", "authority": "m.weibo.cn", "cache-control": "max-age=0", @@ -121,9 +123,11 @@ class Weibo(NewMessage): "sec-fetch-mode": "same-origin", "sec-fetch-site": "same-origin", "upgrade-insecure-requests": "1", - "user-agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) " - "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 " - "Mobile Safari/537.36", + "user-agent": ( + "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) " + "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 " + "Mobile Safari/537.36" + ), } info = raw_post["mblog"] retweeted = False diff --git a/nonebot_bison/plugin_config.py b/nonebot_bison/plugin_config.py index 041b38a..842bf40 100644 --- a/nonebot_bison/plugin_config.py +++ b/nonebot_bison/plugin_config.py @@ -16,9 +16,7 @@ class PlugConfig(BaseSettings): bison_resend_times: int = 0 bison_proxy: str | None bison_ua: str = ( - "Mozilla/5.0 (X11; Linux x86_64) " - "AppleWebKit/537.36 (KHTML, like Gecko) " - "Chrome/51.0.2704.103 Safari/537.36" + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" ) bison_show_network_warning: bool = True diff --git a/nonebot_bison/scheduler/scheduler.py b/nonebot_bison/scheduler/scheduler.py index 2d1d606..bff3791 100644 --- a/nonebot_bison/scheduler/scheduler.py +++ b/nonebot_bison/scheduler/scheduler.py @@ -69,9 +69,7 @@ class Scheduler: if not (schedulable := await self.get_next_schedulable()): return logger.trace(f"scheduler {self.name} fetching next target: [{schedulable.platform_name}]{schedulable.target}") - send_userinfo_list = await config.get_platform_target_subscribers( - schedulable.platform_name, schedulable.target - ) + send_userinfo_list = await config.get_platform_target_subscribers(schedulable.platform_name, schedulable.target) client = await self.scheduler_config_obj.get_client(schedulable.target) context.register_to_client(client) diff --git a/nonebot_bison/sub_manager/add_sub.py b/nonebot_bison/sub_manager/add_sub.py index af676d8..7bf7f1e 100644 --- a/nonebot_bison/sub_manager/add_sub.py +++ b/nonebot_bison/sub_manager/add_sub.py @@ -91,7 +91,7 @@ def do_add_sub(add_sub: type[Matcher]): else: await add_sub.send( f"即将订阅的用户为:{state['platform']} {state['name']} {state['id']}\n如有错误请输入“取消”重新订阅" - ) # noqa: E501 + ) @add_sub.handle() async def prepare_get_categories(matcher: Matcher, state: T_State): @@ -120,7 +120,9 @@ def do_add_sub(add_sub: type[Matcher]): matcher.set_arg("raw_tags", None) # type: ignore state["tags"] = [] return - state["_prompt"] = "请输入要订阅/屏蔽的标签(不含#号)\n" "多个标签请使用空格隔开\n" '订阅所有标签输入"全部标签"\n' '具体规则回复"详情"' # noqa: E501 + state["_prompt"] = ( + '请输入要订阅/屏蔽的标签(不含#号)\n多个标签请使用空格隔开\n订阅所有标签输入"全部标签"\n具体规则回复"详情"' + ) @add_sub.got("raw_tags", MessageTemplate("{_prompt}"), [handle_cancel]) async def parser_tags(state: T_State, raw_tags: Message = Arg()): diff --git a/nonebot_bison/utils/context.py b/nonebot_bison/utils/context.py index 9a66390..83403a0 100644 --- a/nonebot_bison/utils/context.py +++ b/nonebot_bison/utils/context.py @@ -33,9 +33,7 @@ class ProcessContext: res = [] for req in self.reqs: if self._should_print_content(req): - log_content = ( - f"{req.request.url} {req.request.headers} | [{req.status_code}] {req.headers} {req.text}" - ) + log_content = f"{req.request.url} {req.request.headers} | [{req.status_code}] {req.headers} {req.text}" else: log_content = ( f"{req.request.url} {req.request.headers} | [{req.status_code}] {req.headers} " diff --git a/pyproject.toml b/pyproject.toml index 1a2e9a4..e2941fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,7 +85,8 @@ line-length = 120 target-version = "py310" [tool.black] -line-length = 118 +line-length = 120 +preview = true target-version = ["py310", "py311"] include = '\.pyi?$' extend-exclude = ''' diff --git a/tests/platforms/test_bilibili.py b/tests/platforms/test_bilibili.py index 3f29200..c912748 100644 --- a/tests/platforms/test_bilibili.py +++ b/tests/platforms/test_bilibili.py @@ -45,7 +45,10 @@ async def test_video_forward(bilibili, bing_dy_list): post = await bilibili.parse(bing_dy_list[1]) assert ( post.text - == "答案揭晓:宿舍!来看看投票结果\nhttps://t.bilibili.com/568093580488553786\n--------------\n#可露希尔的秘密档案# \n11:来宿舍休息一下吧 \n档案来源:lambda:\\罗德岛内务\\秘密档案 \n发布时间:9/12 1:00 P.M. \n档案类型:可见 \n档案描述:今天请了病假在宿舍休息。很舒适。 \n提供者:赫默\n=================\n《可露希尔的秘密档案》11话:来宿舍休息一下吧" # noqa: E501 + == "答案揭晓:宿舍!来看看投票结果\nhttps://t.bilibili.com/568093580488553786\n--------------\n#可露希尔的秘密档案#" + " \n11:来宿舍休息一下吧 \n档案来源:lambda:\\罗德岛内务\\秘密档案 \n发布时间:9/12 1:00 P.M." + " \n档案类型:可见 \n档案描述:今天请了病假在宿舍休息。很舒适。" + " \n提供者:赫默\n=================\n《可露希尔的秘密档案》11话:来宿舍休息一下吧" ) @@ -54,9 +57,17 @@ async def test_article_forward(bilibili, bing_dy_list): post = await bilibili.parse(bing_dy_list[4]) assert ( post.text - == "#明日方舟##饼学大厦#\n9.11专栏更新完毕,这还塌了实属没跟新运营对上\n后边除了周日发饼和PV没提及的中文语音,稳了\n别忘了来参加#可露希尔的秘密档案#的主题投票\nhttps://t.bilibili.com/568093580488553786?tab=2" + == "#明日方舟##饼学大厦#\n9.11专栏更新完毕," + "这还塌了实属没跟新运营对上\n后边除了周日发饼和PV没提及的中文语音," + "稳了\n别忘了来参加#可露希尔的秘密档案#的主题投票\nhttps://t.bilibili.com/568093580488553786?tab=2" + "\n--------------\n" - + "【明日方舟】饼学大厦#12~14(风暴瞭望&玛莉娅·临光&红松林&感谢庆典)9.11更新 更新记录09.11更新:覆盖09.10更新;以及排期更新,猜测周一周五开活动09.10更新:以周五开活动为底,PV/公告调整位置,整体结构更新09.08更新:饼学大厦#12更新,新增一件六星商店服饰(周日发饼)09.06更新:饼学大厦整栋整栋翻新,改为9.16开主线(四日无饼!)09.05凌晨更新:10.13后的排期(两日无饼,鹰角背刺,心狠手辣)前言感谢楪筱祈ぺ的动态-哔哩哔哩 (bilibili.com) 对饼学的贡献!后续排期:9.17【风暴瞭望】、10.01【玛莉娅·临光】复刻、10.1" # noqa: E501 + + "【明日方舟】饼学大厦#12~14(风暴瞭望&玛莉娅·临光&红松林&感谢庆典)9.11更新" + " 更新记录09.11更新:覆盖09.10更新;以及排期更新,猜测周一周五开活动09.10更新:以周五开活动为底," + "PV/公告调整位置,整体结构更新09.08更新:饼学大厦#12更新," + "新增一件六星商店服饰(周日发饼)09.06更新:饼学大厦整栋整栋翻新," + "改为9.16开主线(四日无饼!)09.05凌晨更新:10.13后的排期(两日无饼,鹰角背刺," + "心狠手辣)前言感谢楪筱祈ぺ的动态-哔哩哔哩 (bilibili.com) 对饼学的贡献!后续排期:9.17【风暴瞭望】、" + "10.01【玛莉娅·临光】复刻、10.1" ) @@ -65,9 +76,14 @@ async def test_dynamic_forward(bilibili, bing_dy_list): post = await bilibili.parse(bing_dy_list[5]) assert ( post.text - == "饼组主线饼学预测——9.11版\n①今日结果\n9.11 殿堂上的游禽-星极(x,新运营实锤了)\n②后续预测\n9.12 #罗德岛相簿#+#可露希尔的秘密档案#11话\n9.13 六星先锋(执旗手)干员-琴柳\n9.14 宣传策略-空弦+家具\n9.15 轮换池(+中文语音前瞻)\n9.16 停机\n9.17 #罗德岛闲逛部#+新六星EP+EP09·风暴瞭望开启\n9.19 #罗德岛相簿#" # noqa: E501 + == "饼组主线饼学预测——9.11版\n①今日结果\n9.11 殿堂上的游禽-星极(x," + "新运营实锤了)\n②后续预测\n9.12 #罗德岛相簿#+#可露希尔的秘密档案#11话\n9.13" + " 六星先锋(执旗手)干员-琴柳\n9.14 宣传策略-空弦+家具\n9.15 轮换池(+中文语音前瞻)\n9.16" + " 停机\n9.17 #罗德岛闲逛部#+新六星EP+EP09·风暴瞭望开启\n9.19 #罗德岛相簿#" + "\n--------------\n" - + "#明日方舟#\n【新增服饰】\n//殿堂上的游禽 - 星极\n塞壬唱片偶像企划《闪耀阶梯》特供服饰/殿堂上的游禽。星极自费参加了这项企划,尝试着用大众能接受的方式演绎天空之上的故事。\n\n_____________\n谦逊留给观众,骄傲发自歌喉,此夜,唯我璀璨。 " # noqa: E501 + + "#明日方舟#\n【新增服饰】\n//殿堂上的游禽 - 星极\n塞壬唱片偶像企划《闪耀阶梯》特供服饰/殿堂上的游禽。" + "星极自费参加了这项企划,尝试着用大众能接受的方式演绎天空之上的故事。\n\n_____________\n谦逊留给观众," + "骄傲发自歌喉,此夜,唯我璀璨。 " ) @@ -108,7 +124,9 @@ async def test_fetch_new(bilibili, dummy_user_subinfo): post = res2[0][1][0] assert ( post.text - == "#罗德厨房——回甘##明日方舟#\r\n明日方舟官方美食漫画,正式开餐。\r\n往事如烟,安然即好。\r\nMenu 01:高脚羽兽烤串与罗德岛的领袖\r\n\r\n哔哩哔哩漫画阅读:https://manga.bilibili.com/detail/mc31998?from=manga_search\r\n\r\n关注并转发本动态,我们将会在5月27日抽取10位博士赠送【兔兔奇境】周边礼盒一份。 互动抽奖" # noqa: E501 + == "#罗德厨房——回甘##明日方舟#\r\n明日方舟官方美食漫画,正式开餐。\r\n往事如烟,安然即好。\r\nMenu" + " 01:高脚羽兽烤串与罗德岛的领袖\r\n\r\n哔哩哔哩漫画阅读:https://manga.bilibili.com/detail/mc31998?from=manga_search\r\n\r\n关注并转发本动态," + "我们将会在5月27日抽取10位博士赠送【兔兔奇境】周边礼盒一份。 互动抽奖" ) diff --git a/tests/platforms/test_platform.py b/tests/platforms/test_platform.py index 8692acf..c8a7462 100644 --- a/tests/platforms/test_platform.py +++ b/tests/platforms/test_platform.py @@ -349,9 +349,7 @@ async def test_new_message_target_without_cats_tags(mock_platform_without_cats_t async def test_new_message_target(mock_platform, user_info_factory): from nonebot_bison.utils import ProcessContext - res1 = await mock_platform(ProcessContext(), AsyncClient()).fetch_new_post( - "dummy", [user_info_factory([1, 2], [])] - ) + res1 = await mock_platform(ProcessContext(), AsyncClient()).fetch_new_post("dummy", [user_info_factory([1, 2], [])]) assert len(res1) == 0 res2 = await mock_platform(ProcessContext(), AsyncClient()).fetch_new_post( "dummy", diff --git a/tests/platforms/test_weibo.py b/tests/platforms/test_weibo.py index c8c0baf..14148b8 100644 --- a/tests/platforms/test_weibo.py +++ b/tests/platforms/test_weibo.py @@ -117,7 +117,17 @@ async def test_rsshub_compare(weibo): test_post = { "mblog": { - "text": '#刚出生的小羊驼长啥样#
小羊驼三三来也[好喜欢]
小羊驼三三 ', # noqa + "text": ( # noqa + '#刚出生的小羊驼长啥样#
小羊驼三三来也[好喜欢]'
小羊驼三三 ' + ), "bid": "KnssqeqKK", } } diff --git a/tests/sub_manager/test_abort.py b/tests/sub_manager/test_abort.py index 4419ee2..ba9783b 100644 --- a/tests/sub_manager/test_abort.py +++ b/tests/sub_manager/test_abort.py @@ -249,7 +249,10 @@ async def test_abort_del_sub(app: App, init_scheduler): should_send_saa( ctx, MessageFactory( - "订阅的帐号为:\n1 weibo 明日方舟Arknights 6279793937\n [图文] 明日方舟\n请输入要删除的订阅的序号\n输入'取消'中止" # noqa: E501 + "订阅的帐号为:\n" + + "1 weibo 明日方舟Arknights 6279793937\n" + + " [图文] 明日方舟\n" + + "请输入要删除的订阅的序号\n输入'取消'中止", ), bot, event=event, diff --git a/tests/sub_manager/test_query_del.py b/tests/sub_manager/test_query_del.py index d2cddaa..d5c0141 100644 --- a/tests/sub_manager/test_query_del.py +++ b/tests/sub_manager/test_query_del.py @@ -67,7 +67,10 @@ async def test_del_sub(app: App, init_scheduler): should_send_saa( ctx, MessageFactory( - "订阅的帐号为:\n1 weibo 明日方舟Arknights 6279793937\n [图文] 明日方舟\n请输入要删除的订阅的序号\n输入'取消'中止" # noqa: E501 + "订阅的帐号为:\n" + + "1 weibo 明日方舟Arknights 6279793937\n" + + " [图文] 明日方舟\n" + + "请输入要删除的订阅的序号\n输入'取消'中止", ), bot, event=event, diff --git a/tests/test_context.py b/tests/test_context.py index 74daa4a..26910d7 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -16,5 +16,8 @@ async def test_http_error(app: App): await client.get("https://example.com") assert ctx.gen_req_records() == [ - "https://example.com Headers({'host': 'example.com', 'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'}) | [403] Headers({'content-length': '15', 'content-type': 'application/json'}) {\"error\": \"gg\"}" # noqa: E501 + "https://example.com Headers({'host': 'example.com', 'accept': '*/*', 'accept-encoding': 'gzip, deflate'," + " 'connection': 'keep-alive', 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like" + " Gecko) Chrome/51.0.2704.103 Safari/537.36'}) | [403] Headers({'content-length': '15', 'content-type':" + ' \'application/json\'}) {"error": "gg"}' ] diff --git a/tests/test_custom_post.py b/tests/test_custom_post.py index 90e8709..b60a9d3 100644 --- a/tests/test_custom_post.py +++ b/tests/test_custom_post.py @@ -24,7 +24,10 @@ def ms_list(): @pytest.fixture() def expected_md(): - return "【Zc】每早合约日替攻略!
![Image](http://i0.hdslb.com/bfs/live/new_room_cover/cf7d4d3b2f336c6dba299644c3af952c5db82612.jpg)\n来源: Bilibili直播 魔法Zc目录
详情: https://live.bilibili.com/3044248
" # noqa: E501 + return ( + "【Zc】每早合约日替攻略!
![Image](http://i0.hdslb.com/bfs/live/new_room_cover/cf7d4d3b2f336c6dba299644c3af952c5db82612.jpg)\n来源:" + " Bilibili直播 魔法Zc目录
详情: https://live.bilibili.com/3044248
" + ) def test_gene_md(app: App, expected_md, ms_list): diff --git a/tests/test_render.py b/tests/test_render.py index 8315063..aad9677 100644 --- a/tests/test_render.py +++ b/tests/test_render.py @@ -13,13 +13,10 @@ async def test_render(app: App): plugin_config.bison_use_pic = True res = await parse_text( - """a\nbbbbbbbbbbbbbbbbbbbbbb\ncd -

中文

-VuePress 由两部分组成:第一部分是一个极简静态网站生成器 - -(opens new window),它包含由 Vue 驱动的主题系统和插件 API,另一个部分是为书写技术文档而优化的默认主题,它的诞生初衷是为了支持 Vue 及其子项目的文档需求。 - -每一个由 VuePress 生成的页面都带有预渲染好的 HTML,也因此具有非常好的加载性能和搜索引擎优化(SEO)。同时,一旦页面被加载,Vue 将接管这些静态内容,并将其转换成一个完整的单页应用(SPA),其他的页面则会只在用户浏览到的时候才按需加载。 -""" # noqa: E501 + "a\nbbbbbbbbbbbbbbbbbbbbbb\ncd\n

中文

VuePress 由两部分组成:第一部分是一个极简静态网站生成器(opens new" + " window),它包含由 Vue 驱动的主题系统和插件 API,另一个部分是为书写技术文档而优化的默认主题," + "它的诞生初衷是为了支持 Vue 及其子项目的文档需求。每一个由 VuePress 生成的页面都带有预渲染好的 HTML," + "也因此具有非常好的加载性能和搜索引擎优化(SEO)。同时,一旦页面被加载,Vue 将接管这些静态内容," + "并将其转换成一个完整的单页应用(SPA),其他的页面则会只在用户浏览到的时候才按需加载。" ) assert isinstance(res, Image) diff --git a/tests/utils.py b/tests/utils.py index 75dbb2a..a6a887d 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -117,7 +117,8 @@ class BotReply: @staticmethod def add_reply_on_cats(platform_manager, platform: str): return ( - f"请输入要订阅的类别,以空格分隔,支持的类别有:{' '.join(list(platform_manager[platform].categories.values()))}" # noqa: E501 + "请输入要订阅的类别,以空格分隔," + f"支持的类别有:{' '.join(list(platform_manager[platform].categories.values()))}" ) @staticmethod @@ -138,6 +139,8 @@ class BotReply: add_reply_on_id_input_error = "id输入错误" add_reply_on_target_parse_input_error = "不能从你的输入中提取出id,请检查你输入的内容是否符合预期" add_reply_on_platform_input_error = "平台输入错误" - add_reply_on_tags = '请输入要订阅/屏蔽的标签(不含#号)\n多个标签请使用空格隔开\n订阅所有标签输入"全部标签"\n具体规则回复"详情"' # noqa: E501 - add_reply_on_tags_need_more_info = "订阅标签直接输入标签内容\n屏蔽标签请在标签名称前添加~号\n详见https://nonebot-bison.netlify.app/usage/#%E5%B9%B3%E5%8F%B0%E8%AE%A2%E9%98%85%E6%A0%87%E7%AD%BE-tag" # noqa: E501 + add_reply_on_tags = ( + '请输入要订阅/屏蔽的标签(不含#号)\n多个标签请使用空格隔开\n订阅所有标签输入"全部标签"\n具体规则回复"详情"' + ) + add_reply_on_tags_need_more_info = "订阅标签直接输入标签内容\n屏蔽标签请在标签名称前添加~号\n详见https://nonebot-bison.netlify.app/usage/#%E5%B9%B3%E5%8F%B0%E8%AE%A2%E9%98%85%E6%A0%87%E7%AD%BE-tag" add_reply_abort = "已中止订阅"