mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 04:57:54 +00:00
Handle logging of sets
This commit is contained in:
parent
16aa5fece2
commit
0bd402e680
@ -88,6 +88,21 @@ def passes():
|
||||
return AfterPreprocessing(run, Equals(True))
|
||||
|
||||
|
||||
class BytesEliotJSONEncoderTests(TestCase):
|
||||
"""Tests for ``BytesEliotJSONEncoder``."""
|
||||
|
||||
def test_encoding_bytes(self):
|
||||
"""``BytesEliotJSONEncoder`` can encode bytes."""
|
||||
encoder = BytesEliotJSONEncoder()
|
||||
self.assertEqual(encoder.default(b"xxx"), "xxx")
|
||||
self.assertEqual(encoder.default(bytes([12])), "\x0c")
|
||||
|
||||
def test_encoding_sets(self):
|
||||
"""``BytesEliotJSONEncoder`` can encode sets."""
|
||||
encoder = BytesEliotJSONEncoder()
|
||||
self.assertIn(encoder.default({1, 2}), ([1, 2], [2, 1]))
|
||||
|
||||
|
||||
class EliotLoggedTestTests(TestCase):
|
||||
"""
|
||||
Tests for the automatic log-related provided by ``AsyncTestCase``.
|
||||
|
@ -85,6 +85,8 @@ class BytesEliotJSONEncoder(EliotJSONEncoder):
|
||||
def default(self, o):
|
||||
if isinstance(o, bytes):
|
||||
return o.decode("utf-8", "backslashreplace")
|
||||
if isinstance(o, set):
|
||||
return list(o)
|
||||
return EliotJSONEncoder.default(self, o)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user