本文整理汇总了Python中thriftpy.transport.memory.TCyMemoryBuffer类的典型用法代码示例。如果您正苦于以下问题:Python TCyMemoryBuffer类的具体用法?Python TCyMemoryBuffer怎么用?Python TCyMemoryBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TCyMemoryBuffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_read_empty_struct
def test_read_empty_struct():
b = TCyMemoryBuffer(b"\x00")
b = proto.TCyBinaryProtocol(b)
_item = TItem()
_item2 = TItem()
b.read_struct(_item2)
assert _item == _item2
开发者ID:GuoJing,项目名称:thriftpy,代码行数:7,代码来源:test_protocol_cybinary.py
示例2: test_write_message_begin_no_strict
def test_write_message_begin_no_strict():
trans = TCyMemoryBuffer()
b = proto.TCyBinaryProtocol(trans, strict_write=False)
b.write_message_begin("test", TType.STRING, 1)
b.write_message_end()
assert "00 00 00 04 74 65 73 74 0b 00 00 00 01" == \
hexlify(trans.getvalue())
开发者ID:GuoJing,项目名称:thriftpy,代码行数:7,代码来源:test_protocol_cybinary.py
示例3: test_write_empty_struct
def test_write_empty_struct():
trans = TCyMemoryBuffer()
b = proto.TCyBinaryProtocol(trans)
item = TItem()
b.write_struct(item)
b.write_message_end()
assert "00" == hexlify(trans.getvalue())
开发者ID:GuoJing,项目名称:thriftpy,代码行数:7,代码来源:test_protocol_cybinary.py
示例4: test_byteswap_i16
def test_byteswap_i16():
i = 128
b = TCyMemoryBuffer()
proto.write_val(b, TType.I16, i)
b.flush()
v = proto.read_val(b, TType.I16)
assert v == i
开发者ID:hand515,项目名称:thriftpy,代码行数:7,代码来源:test_protocol_cybinary.py
示例5: test_skip_double
def test_skip_double():
b = TCyMemoryBuffer()
proto.write_val(b, TType.DOUBLE, 0.123425897)
proto.write_val(b, TType.I32, 123)
b.flush()
proto.skip(b, TType.DOUBLE)
assert 123 == proto.read_val(b, TType.I32)
开发者ID:GuoJing,项目名称:thriftpy,代码行数:8,代码来源:test_protocol_cybinary.py
示例6: test_skip_list
def test_skip_list():
b = TCyMemoryBuffer()
proto.write_val(b, TType.LIST, [5, 6, 7, 8, 9], spec=TType.I32)
proto.write_val(b, TType.I32, 123)
b.flush()
proto.skip(b, TType.LIST)
assert 123 == proto.read_val(b, TType.I32)
开发者ID:GuoJing,项目名称:thriftpy,代码行数:8,代码来源:test_protocol_cybinary.py
示例7: test_skip_map
def test_skip_map():
b = TCyMemoryBuffer()
proto.write_val(b, TType.MAP, {"hello": 0.3456}, spec=(TType.STRING, TType.DOUBLE))
proto.write_val(b, TType.I32, 123)
b.flush()
proto.skip(b, TType.MAP)
assert 123 == proto.read_val(b, TType.I32)
开发者ID:hand515,项目名称:thriftpy,代码行数:8,代码来源:test_protocol_cybinary.py
示例8: test_skip_string
def test_skip_string():
b = TCyMemoryBuffer()
proto.write_val(b, TType.STRING, "hello world")
proto.write_val(b, TType.I32, 123)
b.flush()
proto.skip(b, TType.STRING)
assert 123 == proto.read_val(b, TType.I32)
开发者ID:GuoJing,项目名称:thriftpy,代码行数:8,代码来源:test_protocol_cybinary.py
示例9: test_skip_bool
def test_skip_bool():
b = TCyMemoryBuffer()
proto.write_val(b, TType.BOOL, 1)
proto.write_val(b, TType.I32, 123)
b.flush()
proto.skip(b, TType.BOOL)
assert 123 == proto.read_val(b, TType.I32)
开发者ID:GuoJing,项目名称:thriftpy,代码行数:8,代码来源:test_protocol_cybinary.py
示例10: test_write_struct
def test_write_struct():
trans = TCyMemoryBuffer()
b = proto.TCyBinaryProtocol(trans)
item = TItem(id=123, phones=["123456", "abcdef"])
b.write_struct(item)
b.write_message_end()
assert ("08 00 01 00 00 00 7b 0f 00 02 0b 00 00 00 02 00 00 00 "
"06 31 32 33 34 35 36 00 00 00 06 61 62 63 64 65 66 00") == \
hexlify(trans.getvalue())
开发者ID:GuoJing,项目名称:thriftpy,代码行数:9,代码来源:test_protocol_cybinary.py
示例11: test_read_struct
def test_read_struct():
b = TCyMemoryBuffer(b"\x08\x00\x01\x00\x00\x00{"
b"\x0f\x00\x02\x0b\x00\x00\x00"
b"\x02\x00\x00\x00\x06123456"
b"\x00\x00\x00\x06abcdef\x00")
b = proto.TCyBinaryProtocol(b)
_item = TItem(id=123, phones=["123456", "abcdef"])
_item2 = TItem()
b.read_struct(_item2)
assert _item == _item2
开发者ID:GuoJing,项目名称:thriftpy,代码行数:10,代码来源:test_protocol_cybinary.py
示例12: test_skip_struct
def test_skip_struct():
b = TCyMemoryBuffer()
p = proto.TCyBinaryProtocol(b)
item = TItem(id=123, phones=["123456", "abcdef"])
p.write_struct(item)
p.write_message_end()
proto.write_val(b, TType.I32, 123)
b.flush()
proto.skip(b, TType.STRUCT)
assert 123 == proto.read_val(b, TType.I32)
开发者ID:GuoJing,项目名称:thriftpy,代码行数:12,代码来源:test_protocol_cybinary.py
示例13: test_write_wrong_arg_type
def test_write_wrong_arg_type():
trans = TCyMemoryBuffer()
b = proto.TCyBinaryProtocol(trans)
item = TItem(id="wrong type", phones=["123456", "abcdef"])
try:
b.write_struct(item)
except Exception:
pass
b.write_message_end()
item2 = TItem(id=123, phones=["123456", "abcdef"])
b.write_struct(item2)
b.write_message_end()
assert ("08 00 01 00 00 00 7b 0f 00 02 0b 00 00 00 02 00 00 00 "
"06 31 32 33 34 35 36 00 00 00 06 61 62 63 64 65 66 00") == \
hexlify(trans.getvalue())
开发者ID:GuoJing,项目名称:thriftpy,代码行数:16,代码来源:test_protocol_cybinary.py
示例14: test_write_string
def test_write_string():
b = TCyMemoryBuffer()
proto.write_val(b, TType.STRING, "hello world!")
b.flush()
assert "00 00 00 0c 68 65 6c 6c 6f 20 77 6f 72 6c 64 21" == hexlify(b.getvalue())
b = TCyMemoryBuffer()
proto.write_val(b, TType.STRING, u("你好世界"))
b.flush()
assert "00 00 00 0c e4 bd a0 e5 a5 bd e4 b8 96 e7 95 8c" == hexlify(b.getvalue())
开发者ID:hand515,项目名称:thriftpy,代码行数:10,代码来源:test_protocol_cybinary.py
示例15: test_write_i64
def test_write_i64():
b = TCyMemoryBuffer()
proto.write_val(b, TType.I64, 1234567890123456789)
b.flush()
assert "11 22 10 f4 7d e9 81 15" == hexlify(b.getvalue())
开发者ID:GuoJing,项目名称:thriftpy,代码行数:5,代码来源:test_protocol_cybinary.py
示例16: test_write_i16
def test_write_i16():
b = TCyMemoryBuffer()
proto.write_val(b, TType.I16, 12345)
b.flush()
assert "30 39" == hexlify(b.getvalue())
开发者ID:GuoJing,项目名称:thriftpy,代码行数:6,代码来源:test_protocol_cybinary.py
示例17: test_write_i32
def test_write_i32():
b = TCyMemoryBuffer()
proto.write_val(b, TType.I32, 1234567890)
b.flush()
assert "49 96 02 d2" == hexlify(b.getvalue())
开发者ID:GuoJing,项目名称:thriftpy,代码行数:6,代码来源:test_protocol_cybinary.py
示例18: test_write_i8
def test_write_i8():
b = TCyMemoryBuffer()
proto.write_val(b, TType.I08, 123)
b.flush()
assert "7b" == hexlify(b.getvalue())
开发者ID:GuoJing,项目名称:thriftpy,代码行数:6,代码来源:test_protocol_cybinary.py
示例19: test_write_double
def test_write_double():
b = TCyMemoryBuffer()
proto.write_val(b, TType.DOUBLE, 1234567890.1234567890)
b.flush()
assert "41 d2 65 80 b4 87 e6 b7" == hexlify(b.getvalue())
开发者ID:GuoJing,项目名称:thriftpy,代码行数:5,代码来源:test_protocol_cybinary.py
示例20: test_write_bool
def test_write_bool():
b = TCyMemoryBuffer()
proto.write_val(b, TType.BOOL, 1)
b.flush()
assert "01" == hexlify(b.getvalue())
开发者ID:GuoJing,项目名称:thriftpy,代码行数:6,代码来源:test_protocol_cybinary.py
注:本文中的thriftpy.transport.memory.TCyMemoryBuffer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论