class S(prophy.struct_packed): __metaclass__ = prophy.struct_generator _descriptor = [("a", prophy.u8), ("c_len", prophy.u8), ("e_len", prophy.u8), ("b", prophy.bytes(size=3)), ("c", prophy.bytes(bound="c_len", size=3)), ("d", prophy.array(prophy.u8, size=3)), ("e", prophy.array(prophy.u8, bound="e_len", size=3))]
class Y(prophy.struct): __metaclass__ = prophy.struct_generator _descriptor = [ ("x_len", prophy.u8), ("x", prophy.bytes(bound="x_len")), ("y_len", prophy.u32), ("y", prophy.bytes(bound="y_len")), ("z", prophy.u64) ]
class S( prophy.with_metaclass(prophy.struct_generator, prophy.struct_packed)): _descriptor = [("a_len", prophy.u8), ("a", prophy.bytes(bound="a_len")), ("b_len", prophy.u8), ("b", prophy.array(prophy.u8, bound="b_len"))]
class Object(prophy.struct): __metaclass__ = prophy.struct_generator _descriptor = [('token', Token), ('num_of_values', prophy.u32), ('values', prophy.array(prophy.i64, bound='num_of_values')), ('num_of_updated_values', prophy.u32), ('updated_values', prophy.bytes(bound='num_of_updated_values'))]
class Bytes( prophy.with_metaclass(prophy.struct_generator, prophy.struct_packed)): _descriptor = [("value_len", prophy.u32), ("value", prophy.array(prophy.bytes(size=5), bound="value_len"))]
def test_bytes_bound_attributes(): B = prophy.bytes(bound = "a_len") assert 0 == B._SIZE assert True == B._DYNAMIC assert False == B._UNLIMITED assert '' == B._DEFAULT assert False == B._OPTIONAL assert 1 == B._ALIGNMENT assert "a_len" == B._BOUND assert B._PARTIAL_ALIGNMENT is None
def test_bytes_static_attributes(): B = prophy.bytes(size = 3) assert 3 == B._SIZE assert False == B._DYNAMIC assert False == B._UNLIMITED assert '\x00\x00\x00' == B._DEFAULT assert False == B._OPTIONAL assert 1 == B._ALIGNMENT assert B._BOUND is None assert B._PARTIAL_ALIGNMENT is None
def test_bytes_limited_attributes(): B = prophy.bytes(bound="a_len", size=3) assert B._SIZE == 3 assert B._DYNAMIC is False assert B._UNLIMITED is False assert B._DEFAULT == '' assert B._OPTIONAL is False assert B._ALIGNMENT == 1 assert B._BOUND == "a_len" assert B._PARTIAL_ALIGNMENT is None
def test_bytes_bound_attributes(): B = prophy.bytes(bound="a_len") assert 0 == B._SIZE assert True == B._DYNAMIC assert False == B._UNLIMITED assert '' == B._DEFAULT assert False == B._OPTIONAL assert 1 == B._ALIGNMENT assert "a_len" == B._BOUND assert B._PARTIAL_ALIGNMENT is None
def test_bytes_greedy_attributes(): B = prophy.bytes() assert B._SIZE == 0 assert B._DYNAMIC is True assert B._UNLIMITED is True assert B._DEFAULT == '' assert B._OPTIONAL is False assert B._ALIGNMENT == 1 assert B._BOUND is None assert B._PARTIAL_ALIGNMENT is None
def test_bytes_static_attributes(): B = prophy.bytes(size=3) assert 3 == B._SIZE assert False == B._DYNAMIC assert False == B._UNLIMITED assert '\x00\x00\x00' == B._DEFAULT assert False == B._OPTIONAL assert 1 == B._ALIGNMENT assert B._BOUND is None assert B._PARTIAL_ALIGNMENT is None
def test_bytes_static_attributes(): B = prophy.bytes(size=3) assert B._SIZE == 3 assert B._DYNAMIC is False assert B._UNLIMITED is False assert B._DEFAULT == b'\x00\x00\x00' assert B._OPTIONAL is False assert B._ALIGNMENT == 1 assert B._BOUND is None assert B._PARTIAL_ALIGNMENT is None
class X(prophy.struct_packed): __metaclass__ = prophy.struct_generator _descriptor = [("x", prophy.bytes(size = 5)), ("y", prophy.bytes(size = 5))]
class FixedBytes(prophy.struct_packed): __metaclass__ = prophy.struct_generator _descriptor = [("value", prophy.bytes(size = 5))]
class LastGreedyBytes(prophy.struct_packed): __metaclass__ = prophy.struct_generator _descriptor = [("x", prophy.bytes()), ("y", prophy.u32)]
class GreedyBytes(prophy.struct_packed): __metaclass__ = prophy.struct_generator _descriptor = [("value", prophy.bytes())]
class LimitedBytes(prophy.struct_packed): __metaclass__ = prophy.struct_generator _descriptor = [("value_len", prophy.u32), ("value", prophy.bytes(size = 5, bound = "value_len"))]
class Bytes(prophy.struct_packed): __metaclass__ = prophy.struct_generator _descriptor = [("value_len", prophy.u8), ("value", prophy.bytes(bound = "value_len", size = 1, shift = 2))]
class S1( prophy.with_metaclass(prophy.struct_generator, prophy.struct_packed)): _descriptor = [("a", prophy.bytes())]
def test_optional_bytes(): with pytest.raises(Exception) as e: prophy.optional(prophy.bytes(size=3)) assert "optional bytes not implemented" == str(e.value)
class GreedyBytes( prophy.with_metaclass(prophy.struct_generator, prophy.struct_packed)): _descriptor = [("value", prophy.bytes())]
class X( prophy.with_metaclass(prophy.struct_generator, prophy.struct_packed)): _descriptor = [("x_len", prophy.u32), ("y_len", prophy.u32), ("x", prophy.bytes(size=5, bound="x_len")), ("y", prophy.bytes(size=5, bound="y_len"))]
class Bytes( prophy.with_metaclass(prophy.struct_generator, prophy.struct_packed)): _descriptor = [("value_len", prophy.u8), ("value", prophy.bytes(size=1, shift=2))]
class X(prophy.struct_packed): __metaclass__ = prophy.struct_generator _descriptor = [("x_len", prophy.u32), ("y_len", prophy.u32), ("x", prophy.bytes(bound = "x_len")), ("y", prophy.bytes(bound = "y_len"))]
class ShiftBoundBytes( prophy.with_metaclass(prophy.struct_generator, prophy.struct_packed)): _descriptor = [("value_len", prophy.u8), ("value", prophy.bytes(bound="value_len", shift=2))]
class S1(prophy.struct_packed): __metaclass__ = prophy.struct_generator _descriptor = [("a", prophy.bytes())]
class X( prophy.with_metaclass(prophy.struct_generator, prophy.struct_packed)): _descriptor = [("x", prophy.u32), ("y", prophy.bytes())]
class SBytesSized( prophy.with_metaclass(prophy.struct_generator, prophy.struct_packed)): _descriptor = [("a", prophy.bytes(size=3))]
class Bytes( prophy.with_metaclass(prophy.struct_generator, prophy.struct_packed)): _descriptor = [("z", prophy.u32), ("y", prophy.u32), ("x", prophy.array(prophy.bytes(bound="y"), bound="z"))]
class U1(prophy.with_metaclass(prophy.union_generator, prophy.union)): _descriptor = [("a_len", prophy.u8, 0), ("a", prophy.bytes(bound="a_len", size=3), 1)]
class FixedBytes( prophy.with_metaclass(prophy.struct_generator, prophy.struct_packed)): _descriptor = [("value", prophy.bytes(size=5))]
class U(prophy.with_metaclass(prophy.union_generator, prophy.union)): _descriptor = [("a", prophy.bytes(size=3), 0)]