This commit is contained in:
femto 2023-09-08 11:51:46 +08:00
parent 4f51a5986f
commit e6e72c6e23

View 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