Skip to content

Commit 18164bf

Browse files
authored
test: 修复没有正确 mock 导致 Actions 运行测试时会输出作业摘要的问题 (#322)
1 parent af27dd4 commit 18164bf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/conftest.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def load_plugin(nonebug_init: None) -> set["Plugin"]:
4444

4545

4646
@pytest.fixture
47-
async def app(app: App, tmp_path: Path, mocker: MockerFixture):
47+
async def app(
48+
app: App, tmp_path: Path, mocker: MockerFixture, monkeypatch: pytest.MonkeyPatch
49+
):
4850
from src.plugins.github import plugin_config
4951
from src.providers.utils import dump_json5
5052

@@ -98,6 +100,9 @@ async def app(app: App, tmp_path: Path, mocker: MockerFixture):
98100
mocker.patch.object(
99101
plugin_config, "github_step_summary", tmp_path / "step_summary.txt"
100102
)
103+
# NOTE: 由于 providers 中没有初始化 nonebot,所以不能使用插件中的配置,只能直接使用环境变量。
104+
# 以后需要想想办法,如果能通过 nb-cli 启动就好了。
105+
monkeypatch.setenv("GITHUB_STEP_SUMMARY", str(tmp_path / "step_summary.md"))
101106

102107
yield app
103108

0 commit comments

Comments
 (0)