mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-03 12:52:37 +02:00
test
This commit is contained in:
parent
4f51a5986f
commit
e6e72c6e23
1 changed files with 40 additions and 0 deletions
40
tests/metagpt/utils/test_custom_decoder.py
Normal file
40
tests/metagpt/utils/test_custom_decoder.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Time : 2023/9/8 11:38
|
||||
@Author : femto Zheng
|
||||
@File : test_custom_decoder.py
|
||||
"""
|
||||
import pytest
|
||||
|
||||
import json
|
||||
|
||||
from metagpt.utils.custom_decoder import CustomDecoder
|
||||
|
||||
def test_parse_single_quote():
|
||||
# Create a custom JSON decoder
|
||||
decoder = CustomDecoder(strict=False)
|
||||
# Your provided input with single-quoted strings and line breaks
|
||||
input_data = '''{'a"
|
||||
b':'"title": "Reach and engagement of campaigns",
|
||||
"x-axis": "Low Reach --> High Reach",
|
||||
"y-axis": "Low Engagement --> High Engagement",
|
||||
"quadrant-1": "We should expand",
|
||||
"quadrant-2": "Need to promote",
|
||||
"quadrant-3": "Re-evaluate",
|
||||
"quadrant-4": "May be improved",
|
||||
"Campaign: A": [0.3, 0.6],
|
||||
"Campaign B": [0.45, 0.23],
|
||||
"Campaign C": [0.57, 0.69],
|
||||
"Campaign D": [0.78, 0.34],
|
||||
"Campaign E": [0.40, 0.34],
|
||||
"Campaign F": [0.35, 0.78],
|
||||
"Our Target Product": [0.5, 0.6]
|
||||
'
|
||||
}
|
||||
'''
|
||||
# Parse the JSON using the custom decoder
|
||||
|
||||
parsed_data = decoder.decode(input_data)
|
||||
assert 'a"\n b' in parsed_data
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue