Skip to content

Commit c4d6b37

Browse files
committed
Nested list + frozendict testcase
1 parent fc82117 commit c4d6b37

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Lib/test/test_json/test_decode.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,18 @@ def test_object_pairs_hook(self):
7171

7272
def test_array_hook(self):
7373
s = '[1, 2, 3]'
74-
7574
t = self.loads(s, array_hook=tuple)
7675
self.assertEqual(t, (1, 2, 3))
7776
self.assertEqual(type(t), tuple)
78-
# Array in inner structure
79-
s = '{"xkd": [1, 2, 3]}'
80-
p = {"xkd": (1, 2, 3)}
81-
data = self.loads(s, array_hook=tuple)
77+
# Nested array in inner structure with object_hook
78+
s = '{"xkd": [[1], [2], [3]]}'
79+
p = frozendict(xkd=((1,), (2,), (3,)))
80+
data = self.loads(s, object_hook=frozendict, array_hook=tuple)
8281
self.assertEqual(data, p)
82+
self.assertEqual(type(data), frozendict)
8383
self.assertEqual(type(data["xkd"]), tuple)
84-
84+
for item in data["xkd"]:
85+
self.assertEqual(type(item), tuple)
8586
self.assertEqual(self.loads('[]', array_hook=tuple), ())
8687

8788
def test_decoder_optimizations(self):

0 commit comments

Comments
 (0)