File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -100,3 +100,18 @@ def test_match():
100100def 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
You can’t perform that action at this time.
0 commit comments