From 4f0a42fb60c1e5bbdf33404dc224d5f5b093ef92 Mon Sep 17 00:00:00 2001 From: uy_sun Date: Thu, 12 Dec 2024 09:52:28 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BF=AE=E5=A4=8D=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=20mock=20=E5=AF=BC=E8=87=B4=20Actions=20?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=B5=8B=E8=AF=95=E6=97=B6=E4=BC=9A=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E4=BD=9C=E4=B8=9A=E6=91=98=E8=A6=81=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/conftest.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 06d66a75..56a8f046 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -44,7 +44,9 @@ def load_plugin(nonebug_init: None) -> set["Plugin"]: @pytest.fixture -async def app(app: App, tmp_path: Path, mocker: MockerFixture): +async def app( + app: App, tmp_path: Path, mocker: MockerFixture, monkeypatch: pytest.MonkeyPatch +): from src.plugins.github import plugin_config from src.providers.utils import dump_json5 @@ -98,6 +100,9 @@ async def app(app: App, tmp_path: Path, mocker: MockerFixture): mocker.patch.object( plugin_config, "github_step_summary", tmp_path / "step_summary.txt" ) + # NOTE: 由于 providers 中没有初始化 nonebot,所以不能使用插件中的配置,只能直接使用环境变量。 + # 以后需要想想办法,如果能通过 nb-cli 启动就好了。 + monkeypatch.setenv("GITHUB_STEP_SUMMARY", str(tmp_path / "step_summary.md")) yield app