コード例 #1
0
def test_frameless_extract():
    raw_bytes = valid_msg1 + valid_msg2 + part_1 + part_2 + part_1
    msg, rest = JSONFramingNone.extract_message(raw_bytes)
    assert msg == valid_msg1
    msg, rest = JSONFramingNone.extract_message(rest)
    assert msg == valid_msg2
    msg, rest = JSONFramingNone.extract_message(rest)
    assert msg == (part_1 + part_2)
    msg, rest = JSONFramingNone.extract_message(rest)
    assert msg is None
    assert rest == part_1
コード例 #2
0
def test_frameless_extract():
    raw_bytes = valid_msg1 + valid_msg2 + part_1 + part_2 + part_1
    msg, rest = JSONFramingNone.extract_message(raw_bytes)
    assert msg == valid_msg1
    msg, rest = JSONFramingNone.extract_message(rest)
    assert msg == valid_msg2
    msg, rest = JSONFramingNone.extract_message(rest)
    assert msg == (part_1 + part_2)
    msg, rest = JSONFramingNone.extract_message(rest)
    assert msg is None
    assert rest == part_1
コード例 #3
0
def test_frameless_extract_broken():
    raw_bytes = valid_msg1 + b'  invalid con}ent'
    msg, raw_bytes = JSONFramingNone.extract_message(raw_bytes)
    assert msg == valid_msg1
    with pytest.raises(FramingError):
        JSONFramingNone.extract_message(raw_bytes)
コード例 #4
0
def test_frameless_extract2():
    msg, rest = JSONFramingNone.extract_message(valid_msg3)
    assert msg == valid_msg3
    assert rest == b''
コード例 #5
0
def test_frameless_extract_broken():
    raw_bytes = valid_msg1 + b'  invalid con}ent'
    msg, raw_bytes = JSONFramingNone.extract_message(raw_bytes)
    assert msg == valid_msg1
    with pytest.raises(FramingError):
        JSONFramingNone.extract_message(raw_bytes)
コード例 #6
0
def test_frameless_extract2():
    msg, rest = JSONFramingNone.extract_message(valid_msg3)
    assert msg == valid_msg3
    assert rest == b''