예제 #1
0
def test_codec_to_string(proto, buf, expected):
    assert codec_by_name(proto.codec).to_string(proto, buf) == expected
예제 #2
0
def test_cid_autoconvert_to_string(proto, buf, expected):
    assert codec_by_name("cid").to_string(proto, buf) == expected
예제 #3
0
def test_size_for_addr(codec_name, buf, expected):
    buf_io = io.BytesIO(buf)
    assert (size_for_addr(codec_by_name(codec_name), buf_io), buf_io.tell()) == expected
예제 #4
0
def test_codec_to_string_value_error(proto, buf):
    # Codecs themselves may raise any exception type – it will then be converted
    # to `BinaryParseError` by a higher level
    with pytest.raises(Exception):
        codec_by_name(proto.codec).to_string(proto, buf)
예제 #5
0
def test_cid_autoconvert_to_bytes(proto, string, expected):
    assert codec_by_name("cid").to_bytes(proto, string) == expected
예제 #6
0
def test_codec_to_bytes(proto, string, expected):
    assert codec_by_name(proto.codec).to_bytes(proto, string) == expected
예제 #7
0
def test_codec_to_bytes(proto, string, expected):
    assert codec_by_name(proto.codec).to_bytes(proto, string) == expected
예제 #8
0
def test_codec_to_string(proto, buf, expected):
    assert codec_by_name(proto.codec).to_string(proto, buf) == expected
예제 #9
0
def test_size_for_addr(codec_name, buf, expected):
    assert size_for_addr(codec_by_name(codec_name), buf) == expected
예제 #10
0
def test_codec_to_string_value_error(proto, buf):
    # Codecs themselves may raise any exception type – it will then be converted
    # to `BinaryParseError` by a higher level
    with pytest.raises(Exception):
        codec_by_name(proto.codec).to_string(proto, buf)