fix: Fix json_parsers tests

pull/865/head
Drikus Roor 2023-04-11 23:50:13 +02:00 committed by Drikus Roor
parent ed120c3a39
commit d8f9d1df98
1 changed files with 2 additions and 2 deletions

View File

@ -13,12 +13,12 @@ class TestParseJson(unittest.TestCase):
def test_invalid_json_minor(self):
# Test that an invalid JSON string can be fixed with gpt
json_str = '{"name": "John", "age": 30, "city": "New York",}'
self.assertEqual(fix_and_parse_json(json_str, try_to_fix_with_gpt=False), {"name": "John", "age": 30, "city": "New York"})
self.assertRaises(Exception, fix_and_parse_json, json_str, try_to_fix_with_gpt=False)
def test_invalid_json_major_with_gpt(self):
# Test that an invalid JSON string raises an error when try_to_fix_with_gpt is False
json_str = 'BEGIN: "name": "John" - "age": 30 - "city": "New York" :END'
self.assertEqual(fix_and_parse_json(json_str, try_to_fix_with_gpt=True), {"name": "John", "age": 30, "city": "New York"})
self.assertRaises(Exception, fix_and_parse_json, json_str, try_to_fix_with_gpt=False)
def test_invalid_json_major_without_gpt(self):
# Test that a REALLY invalid JSON string raises an error when try_to_fix_with_gpt is False