Skip to content

Commit ae8bc2e

Browse files
committed
added test case "test_bintype_symmetry" (see issue #281)
1 parent 4b72b61 commit ae8bc2e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/test_case.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,18 @@ def test_match():
100100
def test_unicode():
101101
assert unpackb(packb('foobar'), use_list=1) == b'foobar'
102102

103+
def test_bintype_symmetry():
104+
# For background on this test see github issue #281
105+
# - basically: packing with use_bin_type=True and unpacking with raw=False
106+
# should be completely symmetric
107+
buf = b'\x92\xa3\xe2\x98\x83\xc4\x03\x00\x01\x02'
108+
unpacked = unpackb(buf, raw=False)
109+
packed = packb(unpacked, use_bin_type=True)
110+
assert packed == buf
111+
# Also confirm that unpacking went to the expected types
112+
# - Note that we can't use test_match since it just uses basic equality
113+
# testing. We need to assert exact type matching here.
114+
expected = [u'\u2603', b'\x00\x01\x02']
115+
for x, y in zip(expected, unpacked):
116+
assert type(x) is type(y)
117+
assert x == y

0 commit comments

Comments
 (0)