X-Git-Url: https://code.kerkeslager.com/?p=sandbox;a=blobdiff_plain;f=serial%2Ftest_binary.py;h=4da6e1bf6245aaaf4a730dc3736f0aca0e0a2acb;hp=95652cb5d3a50c1307489b5e378c8a52ee8712ed;hb=07d76f810ece3b43bb837e81ceb3a8b441348ba3;hpb=dd212c690a8c472d4dabf869f9349510ac906c90 diff --git a/serial/test_binary.py b/serial/test_binary.py index 95652cb..4da6e1b 100644 --- a/serial/test_binary.py +++ b/serial/test_binary.py @@ -26,22 +26,34 @@ EXAMPLE_REPRESENTATIONS = [ (binary.TaggedObject(binary.TAG_UTF8, 'Lol!'), b'\x21\x00\x00\x00\x04Lol!'), (binary.TaggedObject(binary.TAG_UTF16, 'かわ'), b'\x22\x00\x00\x00\x06\xff\xfeK0\x8f0'), (binary.TaggedObject(binary.TAG_UTF32, '漢'), b'\x23\x00\x00\x00\x08\xff\xfe\x00\x00"o\x00\x00'), + ( + binary.TaggedObject( + binary.TAG_TUPLE, + ( + binary.TaggedObject( + binary.TAG_TRUE, + True, + ), + binary.TaggedObject( + binary.TAG_UINT8, + 7, + ), + ), + ), + b'\x30\x00\x00\x00\x03\x01\x03\x07' + ), ] class SerializeTests(unittest.TestCase): def test_serialize(self): - for tagged_object, representation in EXAMPLE_REPRESENTATIONS: - self.assertEqual( - binary.serialize(tagged_object), - representation, - ) + for tagged_object, expected in EXAMPLE_REPRESENTATIONS: + actual = binary.serialize(tagged_object) + self.assertEqual(expected, actual) class DeserializeTests(unittest.TestCase): def test_deserialize(self): - for tagged_object, representation in EXAMPLE_REPRESENTATIONS: - self.assertEqual( - binary.deserialize(representation), - tagged_object, - ) + for expected, representation in EXAMPLE_REPRESENTATIONS: + actual = binary.deserialize(representation) + self.assertEqual(expected, actual) unittest.main()