(app: App, monkeypatch: pytest.MonkeyPatch)
| 59 | |
| 60 | @pytest.mark.anyio |
| 61 | async def test_event_preprocessor_ignore(app: App, monkeypatch: pytest.MonkeyPatch): |
| 62 | with monkeypatch.context() as m: |
| 63 | m.setattr(message, "_event_preprocessors", set()) |
| 64 | |
| 65 | @event_preprocessor |
| 66 | async def test_preprocessor(): |
| 67 | raise IgnoredException("pass") |
| 68 | |
| 69 | assert test_preprocessor in { |
| 70 | dependent.call for dependent in message._event_preprocessors |
| 71 | } |
| 72 | |
| 73 | runned = False |
| 74 | |
| 75 | async def handler(): |
| 76 | nonlocal runned |
| 77 | runned = True |
| 78 | |
| 79 | with app.provider.context({}): |
| 80 | matcher = on_message(handlers=[handler]) |
| 81 | |
| 82 | async with app.test_matcher(matcher) as ctx: |
| 83 | bot = ctx.create_bot() |
| 84 | event = make_fake_event()() |
| 85 | ctx.receive_event(bot, event) |
| 86 | |
| 87 | assert not runned, "matcher should not runned" |
| 88 | |
| 89 | |
| 90 | @pytest.mark.anyio |
nothing calls this directly
no test coverage detected