mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-20 15:38:09 +02:00
add ut test_repair_invalid_json
This commit is contained in:
parent
502bb2c449
commit
c25d5a73d1
2 changed files with 53 additions and 7 deletions
|
|
@ -132,6 +132,48 @@ def test_repair_json_format():
|
|||
assert output == target_output
|
||||
|
||||
|
||||
def test_repair_invalid_json():
|
||||
raw_output = """{
|
||||
"key": "value"
|
||||
},
|
||||
}"""
|
||||
target_output = """{
|
||||
"key": "value"
|
||||
,
|
||||
}"""
|
||||
output = repair_invalid_json(raw_output, "Expecting ',' delimiter: line 3 column 1")
|
||||
assert output == target_output
|
||||
|
||||
raw_output = """{
|
||||
"key": "
|
||||
value
|
||||
},
|
||||
}"""
|
||||
target_output = """{
|
||||
"key": "
|
||||
value
|
||||
",
|
||||
}"""
|
||||
output = repair_invalid_json(raw_output, "Expecting ',' delimiter: line 4 column 1")
|
||||
output = repair_invalid_json(output, "Expecting ',' delimiter: line 4 column 1")
|
||||
assert output == target_output
|
||||
|
||||
raw_output = """{
|
||||
"key": '
|
||||
value
|
||||
},
|
||||
}"""
|
||||
target_output = """{
|
||||
"key": '
|
||||
value
|
||||
',
|
||||
}"""
|
||||
output = repair_invalid_json(raw_output, "Expecting ',' delimiter: line 4 column 1")
|
||||
output = repair_invalid_json(output, "Expecting ',' delimiter: line 4 column 1")
|
||||
output = repair_invalid_json(output, "Expecting ',' delimiter: line 4 column 1")
|
||||
assert output == target_output
|
||||
|
||||
|
||||
def test_retry_parse_json_text():
|
||||
invalid_json_text = """{
|
||||
"Original Requirements": "Create a 2048 game",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue