class Header(base.GenericStruct): """Mock Header class.""" version = basic_types.UBInt8(1) message_type = basic_types.UBInt8(2) length = basic_types.UBInt8(8) xid = basic_types.UBInt8(4)
def setUp(self): """Basic test setup.""" self.ubint8 = basic_types.UBInt8()
def test_pack_error(self): """[Foundation/BasicTypes/UBInt8] - packing exception.""" u = basic_types.UBInt8(256) self.assertRaises(PackException, u.pack)
class AttributeA(base.GenericStruct): """Example class.""" a1 = basic_types.UBInt8(1) a2 = basic_types.UBInt16(2)
def test_unpack(self): """[Foundation/BasicTypes/UBInt8] - unpacking.""" u = basic_types.UBInt8() u.unpack(b'\xfe') self.assertEqual(u.value, 254)