示例#1
0
def test_msg():
    data = list(b'asdf' * x for x in range(256))
    byte_data_gen = msg_to_bytes(data)
    total_len = next(byte_data_gen)
    mv = memoryview(b''.join(byte_data_gen))
    recreated_data = list(msg_from_bytes(mv))
    assert data == recreated_data
示例#2
0
def test_memoryview_wrapper():
    data = list(b'asdf' * x for x in range(256))
    byte_data_gen = msg_to_bytes(data)
    total_len = next(byte_data_gen)
    bytes = b''.join(byte_data_gen)
    mv = memoryview(bytes)
    assert getrefcount(bytes) == 1 + 1 + 1
    assert getrefcount(mv) == 1 + 1
    recreated_data = list(msg_from_bytes(mv))
    assert getrefcount(bytes) == 1 + 1 + 1
    del mv
    del recreated_data
    assert getrefcount(bytes) == 1 + 1