(
app: App, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
)
| 352 | |
| 353 | @pytest.mark.anyio |
| 354 | async def test_run_postprocessor_exception( |
| 355 | app: App, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str] |
| 356 | ): |
| 357 | with monkeypatch.context() as m: |
| 358 | m.setattr(message, "_run_postprocessors", set()) |
| 359 | |
| 360 | @run_postprocessor |
| 361 | async def test_postprocessor(): |
| 362 | raise RuntimeError("test") |
| 363 | |
| 364 | assert test_postprocessor in { |
| 365 | dependent.call for dependent in message._run_postprocessors |
| 366 | } |
| 367 | |
| 368 | handler_id = logger.add( |
| 369 | sys.stdout, |
| 370 | level=0, |
| 371 | diagnose=False, |
| 372 | filter=default_filter, |
| 373 | format=default_format, |
| 374 | ) |
| 375 | |
| 376 | try: |
| 377 | with app.provider.context({}): |
| 378 | matcher = on_message() |
| 379 | |
| 380 | async with app.test_matcher(matcher) as ctx: |
| 381 | bot = ctx.create_bot() |
| 382 | event = make_fake_event()() |
| 383 | ctx.receive_event(bot, event) |
| 384 | finally: |
| 385 | logger.remove(handler_id) |
| 386 | |
| 387 | assert "RuntimeError: test" in capsys.readouterr().out |
nothing calls this directly
no test coverage detected