Skip to content

Commit a328d19

Browse files
committed
More tests for canonicaljson encoding
Test that unicode and frozendicts are encoded correctly
1 parent 5a36a43 commit a328d19

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test_canonicaljson.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,22 @@ class TestCanonicalJson(unittest.TestCase):
2727
def test_encode_canonical(self):
2828
self.assertEquals(encode_canonical_json({}), b'{}')
2929

30+
# non-ascii should come out utf8-encoded.
31+
self.assertEquals(encode_canonical_json({
32+
u"la merde amus\u00c3e": u"\U0001F4A9",
33+
}), b'{"la merde amus\xc3\x83e":"\xF0\x9F\x92\xA9"}')
34+
3035
def test_encode_pretty_printed(self):
3136
self.assertEquals(encode_pretty_printed_json({}), b'{}')
3237

3338
def test_frozen_dict(self):
34-
self.assertEquals(encode_canonical_json(frozendict({})), b'{}')
35-
self.assertEquals(encode_pretty_printed_json(frozendict({})), b'{}')
39+
self.assertEquals(
40+
encode_canonical_json(frozendict({"a": 1})),
41+
b'{"a":1}',
42+
)
43+
self.assertEquals(
44+
encode_pretty_printed_json(frozendict({"a": 1})),
45+
b'{\n "a": 1\n}')
3646

3747
def test_unknown_type(self):
3848
class Unknown(object):

0 commit comments

Comments
 (0)