forked from ijl/orjson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_circular.py
More file actions
34 lines (28 loc) · 827 Bytes
/
Copy pathtest_circular.py
File metadata and controls
34 lines (28 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import unittest
import orjson
class CircularTests(unittest.TestCase):
def test_circular_dict(self):
"""
dumps() circular reference dict
"""
obj = {}
obj["obj"] = obj
with self.assertRaises(orjson.JSONEncodeError):
orjson.dumps(obj)
def test_circular_list(self):
"""
dumps() circular reference list
"""
obj = []
obj.append(obj)
with self.assertRaises(orjson.JSONEncodeError):
orjson.dumps(obj)
def test_circular_nested(self):
"""
dumps() circular reference nested dict, list
"""
obj = {}
obj["list"] = [{"obj": obj}]
with self.assertRaises(orjson.JSONEncodeError):
orjson.dumps(obj)