We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 79961a2 commit 58550c0Copy full SHA for 58550c0
Lib/test/test_struct.py
@@ -802,6 +802,14 @@ def __init__(self):
802
my_struct = MyStruct()
803
self.assertEqual(my_struct.pack(12345), b'\x30\x39')
804
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
813
def test_repr(self):
814
s = struct.Struct('=i2H')
815
self.assertEqual(repr(s), f'Struct({s.format!r})')
0 commit comments