(
app: App, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
)
| 166 | |
| 167 | @pytest.mark.anyio |
| 168 | async def test_event_postprocessor_exception( |
| 169 | app: App, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str] |
| 170 | ): |
| 171 | with monkeypatch.context() as m: |
| 172 | m.setattr(message, "_event_postprocessors", set()) |
| 173 | |
| 174 | @event_postprocessor |
| 175 | async def test_postprocessor(): |
| 176 | raise RuntimeError("test") |
| 177 | |
| 178 | assert test_postprocessor in { |
| 179 | dependent.call for dependent in message._event_postprocessors |
| 180 | } |
| 181 | |
| 182 | handler_id = logger.add( |
| 183 | sys.stdout, |
| 184 | level=0, |
| 185 | diagnose=False, |
| 186 | filter=default_filter, |
| 187 | format=default_format, |
| 188 | ) |
| 189 | |
| 190 | try: |
| 191 | with app.provider.context({}): |
| 192 | matcher = on_message() |
| 193 | |
| 194 | async with app.test_matcher(matcher) as ctx: |
| 195 | bot = ctx.create_bot() |
| 196 | event = make_fake_event()() |
| 197 | ctx.receive_event(bot, event) |
| 198 | finally: |
| 199 | logger.remove(handler_id) |
| 200 | |
| 201 | assert "RuntimeError: test" in capsys.readouterr().out |
| 202 | |
| 203 | |
| 204 | @pytest.mark.anyio |
nothing calls this directly
no test coverage detected