(app: App, monkeypatch: pytest.MonkeyPatch)
| 133 | |
| 134 | @pytest.mark.anyio |
| 135 | async def test_event_postprocessor(app: App, monkeypatch: pytest.MonkeyPatch): |
| 136 | with monkeypatch.context() as m: |
| 137 | m.setattr(message, "_event_postprocessors", set()) |
| 138 | |
| 139 | runned = False |
| 140 | |
| 141 | @event_postprocessor |
| 142 | async def test_postprocessor( |
| 143 | bot: Bot, |
| 144 | event: Event, |
| 145 | state: T_State, |
| 146 | sub: int = Depends(_dependency), |
| 147 | default: int = 1, |
| 148 | ): |
| 149 | nonlocal runned |
| 150 | runned = True |
| 151 | |
| 152 | assert test_postprocessor in { |
| 153 | dependent.call for dependent in message._event_postprocessors |
| 154 | } |
| 155 | |
| 156 | with app.provider.context({}): |
| 157 | matcher = on_message() |
| 158 | |
| 159 | async with app.test_matcher(matcher) as ctx: |
| 160 | bot = ctx.create_bot() |
| 161 | event = make_fake_event()() |
| 162 | ctx.receive_event(bot, event) |
| 163 | |
| 164 | assert runned, "event_postprocessor should runned" |
| 165 | |
| 166 | |
| 167 | @pytest.mark.anyio |
nothing calls this directly
no test coverage detected