(app: App, monkeypatch: pytest.MonkeyPatch)
| 314 | |
| 315 | @pytest.mark.anyio |
| 316 | async def test_run_postprocessor(app: App, monkeypatch: pytest.MonkeyPatch): |
| 317 | with monkeypatch.context() as m: |
| 318 | m.setattr(message, "_run_postprocessors", set()) |
| 319 | |
| 320 | runned = False |
| 321 | |
| 322 | @run_postprocessor |
| 323 | async def test_postprocessor( |
| 324 | bot: Bot, |
| 325 | event: Event, |
| 326 | state: T_State, |
| 327 | matcher: Matcher, |
| 328 | exception: Exception | None, |
| 329 | sub: int = Depends(_dependency), |
| 330 | default: int = 1, |
| 331 | ): |
| 332 | nonlocal runned |
| 333 | runned = True |
| 334 | |
| 335 | await matcher.send("test") |
| 336 | |
| 337 | assert test_postprocessor in { |
| 338 | dependent.call for dependent in message._run_postprocessors |
| 339 | } |
| 340 | |
| 341 | with app.provider.context({}): |
| 342 | matcher = on_message() |
| 343 | |
| 344 | async with app.test_matcher(matcher) as ctx: |
| 345 | bot = ctx.create_bot() |
| 346 | event = make_fake_event()() |
| 347 | ctx.receive_event(bot, event) |
| 348 | ctx.should_call_send(event, "test", True, bot=bot) |
| 349 | |
| 350 | assert runned, "run_postprocessor should runned" |
| 351 | |
| 352 | |
| 353 | @pytest.mark.anyio |
nothing calls this directly
no test coverage detected