當前位置: 首頁>>代碼示例>>Python>>正文


Python TCyMemoryBuffer.flush方法代碼示例

本文整理匯總了Python中thriftpy.transport.memory.TCyMemoryBuffer.flush方法的典型用法代碼示例。如果您正苦於以下問題:Python TCyMemoryBuffer.flush方法的具體用法?Python TCyMemoryBuffer.flush怎麽用?Python TCyMemoryBuffer.flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在thriftpy.transport.memory.TCyMemoryBuffer的用法示例。


在下文中一共展示了TCyMemoryBuffer.flush方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_byteswap_i16

# 需要導入模塊: from thriftpy.transport.memory import TCyMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.memory.TCyMemoryBuffer import flush [as 別名]
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,代碼行數:9,代碼來源:test_protocol_cybinary.py

示例2: test_skip_list

# 需要導入模塊: from thriftpy.transport.memory import TCyMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.memory.TCyMemoryBuffer import flush [as 別名]
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,代碼行數:10,代碼來源:test_protocol_cybinary.py

示例3: test_skip_string

# 需要導入模塊: from thriftpy.transport.memory import TCyMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.memory.TCyMemoryBuffer import flush [as 別名]
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,代碼行數:10,代碼來源:test_protocol_cybinary.py

示例4: test_skip_double

# 需要導入模塊: from thriftpy.transport.memory import TCyMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.memory.TCyMemoryBuffer import flush [as 別名]
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,代碼行數:10,代碼來源:test_protocol_cybinary.py

示例5: test_skip_bool

# 需要導入模塊: from thriftpy.transport.memory import TCyMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.memory.TCyMemoryBuffer import flush [as 別名]
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,代碼行數:10,代碼來源:test_protocol_cybinary.py

示例6: test_skip_map

# 需要導入模塊: from thriftpy.transport.memory import TCyMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.memory.TCyMemoryBuffer import flush [as 別名]
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,代碼行數:10,代碼來源:test_protocol_cybinary.py

示例7: test_write_string

# 需要導入模塊: from thriftpy.transport.memory import TCyMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.memory.TCyMemoryBuffer import flush [as 別名]
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,代碼行數:12,代碼來源:test_protocol_cybinary.py

示例8: test_skip_struct

# 需要導入模塊: from thriftpy.transport.memory import TCyMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.memory.TCyMemoryBuffer import flush [as 別名]
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,代碼行數:14,代碼來源:test_protocol_cybinary.py

示例9: test_write_i64

# 需要導入模塊: from thriftpy.transport.memory import TCyMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.memory.TCyMemoryBuffer import flush [as 別名]
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,代碼行數:7,代碼來源:test_protocol_cybinary.py

示例10: test_write_i32

# 需要導入模塊: from thriftpy.transport.memory import TCyMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.memory.TCyMemoryBuffer import flush [as 別名]
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,代碼行數:8,代碼來源:test_protocol_cybinary.py

示例11: test_write_i16

# 需要導入模塊: from thriftpy.transport.memory import TCyMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.memory.TCyMemoryBuffer import flush [as 別名]
def test_write_i16():
    b = TCyMemoryBuffer()
    proto.write_val(b, TType.I16, 12345)
    b.flush()

    assert "30 39" == hexlify(b.getvalue())
開發者ID:GuoJing,項目名稱:thriftpy,代碼行數:8,代碼來源:test_protocol_cybinary.py

示例12: test_write_i8

# 需要導入模塊: from thriftpy.transport.memory import TCyMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.memory.TCyMemoryBuffer import flush [as 別名]
def test_write_i8():
    b = TCyMemoryBuffer()
    proto.write_val(b, TType.I08, 123)
    b.flush()

    assert "7b" == hexlify(b.getvalue())
開發者ID:GuoJing,項目名稱:thriftpy,代碼行數:8,代碼來源:test_protocol_cybinary.py

示例13: test_write_bool

# 需要導入模塊: from thriftpy.transport.memory import TCyMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.memory.TCyMemoryBuffer import flush [as 別名]
def test_write_bool():
    b = TCyMemoryBuffer()
    proto.write_val(b, TType.BOOL, 1)
    b.flush()

    assert "01" == hexlify(b.getvalue())
開發者ID:GuoJing,項目名稱:thriftpy,代碼行數:8,代碼來源:test_protocol_cybinary.py

示例14: test_write_double

# 需要導入模塊: from thriftpy.transport.memory import TCyMemoryBuffer [as 別名]
# 或者: from thriftpy.transport.memory.TCyMemoryBuffer import flush [as 別名]
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,代碼行數:7,代碼來源:test_protocol_cybinary.py


注:本文中的thriftpy.transport.memory.TCyMemoryBuffer.flush方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。