(app: App, monkeypatch: pytest.MonkeyPatch)
| 203 | |
| 204 | @pytest.mark.anyio |
| 205 | async def test_run_preprocessor(app: App, monkeypatch: pytest.MonkeyPatch): |
| 206 | with monkeypatch.context() as m: |
| 207 | m.setattr(message, "_run_preprocessors", set()) |
| 208 | |
| 209 | runned = False |
| 210 | |
| 211 | @run_preprocessor |
| 212 | async def test_preprocessor( |
| 213 | bot: Bot, |
| 214 | event: Event, |
| 215 | state: T_State, |
| 216 | matcher: Matcher, |
| 217 | sub: int = Depends(_dependency), |
| 218 | default: int = 1, |
| 219 | ): |
| 220 | nonlocal runned |
| 221 | runned = True |
| 222 | |
| 223 | await matcher.send("test") |
| 224 | |
| 225 | assert test_preprocessor in { |
| 226 | dependent.call for dependent in message._run_preprocessors |
| 227 | } |
| 228 | |
| 229 | with app.provider.context({}): |
| 230 | matcher = on_message() |
| 231 | |
| 232 | async with app.test_matcher(matcher) as ctx: |
| 233 | bot = ctx.create_bot() |
| 234 | event = make_fake_event()() |
| 235 | ctx.receive_event(bot, event) |
| 236 | ctx.should_call_send(event, "test", True, bot=bot) |
| 237 | |
| 238 | assert runned, "run_preprocessor should runned" |
| 239 | |
| 240 | |
| 241 | @pytest.mark.anyio |
nothing calls this directly
no test coverage detected