⚡️ 优化自检插件逻辑,增加规则判断,添加nonebug配置 (#1792)

* ⬆️ Expand the range of nonebug version restrictions and update nonebot-plugin-alconna.

* ✅ Update pytest configuration.

* ✅ Add pytest hook to tag async tests with session-scoped event loop.

* ⚡️ 优化自检插件逻辑,增加规则判断

---------

Co-authored-by: BalconyJH <balconyjh@gmail.com>
This commit is contained in:
HibiKier
2024-12-23 10:09:06 +08:00
committed by GitHub
co-authored by BalconyJH
parent 3a197c0c1d
commit 4291cda244
5 changed files with 55 additions and 40 deletions
+8
View File
@@ -8,6 +8,7 @@ from nonebug import NONEBOT_INIT_KWARGS
from nonebug.app import App
from nonebug.mixin.process import MatcherContext
import pytest
from pytest_asyncio import is_async_test
from pytest_mock import MockerFixture
from respx import MockRouter
@@ -22,6 +23,13 @@ def get_response_json(path: str) -> dict:
)
def pytest_collection_modifyitems(items: list[pytest.Item]):
pytest_asyncio_tests = (item for item in items if is_async_test(item))
session_scope_marker = pytest.mark.asyncio(loop_scope="session")
for async_test in pytest_asyncio_tests:
async_test.add_marker(session_scope_marker, append=False)
def pytest_configure(config: pytest.Config) -> None:
config.stash[NONEBOT_INIT_KWARGS] = {
"driver": "~fastapi+~httpx+~websockets",