MCPcopy
hub / github.com/nonebot/nonebot2 / test_event_preprocessor_ignore

Function test_event_preprocessor_ignore

tests/test_broadcast.py:61–87  ·  view source on GitHub ↗
(app: App, monkeypatch: pytest.MonkeyPatch)

Source from the content-addressed store, hash-verified

59
60@pytest.mark.anyio
61async 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

Callers

nothing calls this directly

Calls 2

on_messageFunction · 0.90
make_fake_eventFunction · 0.90

Tested by

no test coverage detected