MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_construct

Method test_construct

Lib/test/test_struct.py:851–870  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

849 """
850
851 def test_construct(self):
852 def _check_iterator(it):
853 self.assertIsInstance(it, abc.Iterator)
854 self.assertIsInstance(it, abc.Iterable)
855 s = struct.Struct('>ibcp')
856 it = s.iter_unpack(b"")
857 _check_iterator(it)
858 it = s.iter_unpack(b"1234567")
859 _check_iterator(it)
860 # Wrong bytes length
861 with self.assertRaises(struct.error):
862 s.iter_unpack(b"123456")
863 with self.assertRaises(struct.error):
864 s.iter_unpack(b"12345678")
865 # Zero-length struct
866 s = struct.Struct('>')
867 with self.assertRaises(struct.error):
868 s.iter_unpack(b"")
869 with self.assertRaises(struct.error):
870 s.iter_unpack(b"12")
871
872 def test_uninstantiable(self):
873 iter_unpack_type = type(struct.Struct(">ibcp").iter_unpack(b""))

Callers

nothing calls this directly

Calls 2

iter_unpackMethod · 0.80
assertRaisesMethod · 0.45

Tested by

no test coverage detected