Skip to content

Commit 58550c0

Browse files
committed
address review: add test
1 parent 79961a2 commit 58550c0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Lib/test/test_struct.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,14 @@ def __init__(self):
802802
my_struct = MyStruct()
803803
self.assertEqual(my_struct.pack(12345), b'\x30\x39')
804804

805+
class MyStruct(struct.Struct):
806+
def __new__(cls, arg):
807+
self = super().__new__(cls, '>h')
808+
return self
809+
810+
my_struct = MyStruct(5)
811+
self.assertEqual(my_struct.pack(123), b'\x00{')
812+
805813
def test_repr(self):
806814
s = struct.Struct('=i2H')
807815
self.assertEqual(repr(s), f'Struct({s.format!r})')

0 commit comments

Comments
 (0)