Exemple #1
0
class UJSONParserTests(TestCase):
    def setUp(self):
        self.parser = UJSONParser()
        self.data = {
            'a': [1, 2, 3],
            'b': True,
            'c': 1.23,
            'd': 'test',
            'e': {'foo': 'bar'},
        }

    def test_basic_data_structures_parsed_correctly(self):

        dumped = ujson.dumps(self.data)
        parsed = self.parser.parse(BytesIO(dumped.encode('utf-8')))

        self.assertEqual(parsed, self.data)

    def test_parser_works_correctly_when_media_type_and_context_provided(self):
        dumped = ujson.dumps(self.data)
        parsed = self.parser.parse(
            stream=BytesIO(dumped.encode('utf-8')),
            media_type='application/json',
            parser_context={},
        )

        self.assertEqual(parsed, self.data)
Exemple #2
0
 def setUp(self):
     self.parser = UJSONParser()
     self.data = {
         'a': [1, 2, 3],
         'b': True,
         'c': 1.23,
         'd': 'test',
         'e': {'foo': 'bar'},
     }
def uut():
    return UJSONParser()