mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-22 06:17:50 +00:00
Improve coverage, specifically of values that are bytes.
This commit is contained in:
parent
a1add9a512
commit
2595e25258
@ -491,12 +491,16 @@ class JSONBytes(unittest.TestCase):
|
|||||||
"""Tests for BytesJSONEncoder."""
|
"""Tests for BytesJSONEncoder."""
|
||||||
|
|
||||||
def test_encode_bytes(self):
|
def test_encode_bytes(self):
|
||||||
"""BytesJSONEncoder can encode bytes."""
|
"""BytesJSONEncoder can encode bytes.
|
||||||
|
|
||||||
|
Bytes are presumed to be UTF-8 encoded.
|
||||||
|
"""
|
||||||
|
snowman = u"def\N{SNOWMAN}\uFF00"
|
||||||
data = {
|
data = {
|
||||||
b"hello": [1, b"cd", {b"abc": 123}],
|
b"hello": [1, b"cd", {b"abc": [123, snowman.encode("utf-8")]}],
|
||||||
}
|
}
|
||||||
expected = {
|
expected = {
|
||||||
u"hello": [1, u"cd", {u"abc": 123}],
|
u"hello": [1, u"cd", {u"abc": [123, snowman]}],
|
||||||
}
|
}
|
||||||
# Bytes get passed through as if they were UTF-8 Unicode:
|
# Bytes get passed through as if they were UTF-8 Unicode:
|
||||||
encoded = jsonbytes.dumps(data)
|
encoded = jsonbytes.dumps(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user