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
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)
def test_frameless_extract2(): msg, rest = JSONFramingNone.extract_message(valid_msg3) assert msg == valid_msg3 assert rest == b''