Fix error handling when JSON can not be parsed.
This commit is contained in:
+2
-3
@@ -1,6 +1,5 @@
|
||||
import os
|
||||
import unittest
|
||||
import pytest
|
||||
import aiohttp
|
||||
import json
|
||||
import toml
|
||||
@@ -118,8 +117,8 @@ class TestFunctionality(TestBotBase):
|
||||
message = self.create_message("Hello there! How are you?")
|
||||
with patch.object(openai.ChatCompletion, 'acreate', new=acreate), \
|
||||
patch.object(logging, 'warning', logging_warning):
|
||||
with pytest.raises(RuntimeError, match='failed.*JSONDecodeError.*'):
|
||||
await self.bot.on_message(message)
|
||||
await self.bot.on_message(message)
|
||||
self.bot.staff_channel.send.assert_called_once_with("ERROR: I could not parse this answer: '{ \"test\": 3 ]'", suppress_embeds=True)
|
||||
|
||||
async def test_on_message_event4(self) -> None:
|
||||
async def acreate(*a, **kw):
|
||||
|
||||
Reference in New Issue
Block a user