Add segment (de)serialization round-trip test.

This commit is contained in:
Constantine Vetoshev
2016-06-23 14:15:39 -07:00
parent 09705b6d1f
commit 73d6c5dc10

View File

@@ -42,6 +42,13 @@ def test_roundtrip_bytes(all_types):
msg = all_types.TestAllTypes.from_bytes(message_bytes) msg = all_types.TestAllTypes.from_bytes(message_bytes)
test_regression.check_all_types(msg) test_regression.check_all_types(msg)
def test_roundtrip_segments(all_types):
msg = all_types.TestAllTypes.new_message()
test_regression.init_all_types(msg)
segments = msg.to_segments()
msg = all_types.TestAllTypes.from_segments(segments)
test_regression.check_all_types(msg)
@pytest.mark.skipif(sys.version_info[0] < 3, reason="mmap doesn't implement the buffer interface under python 2.") @pytest.mark.skipif(sys.version_info[0] < 3, reason="mmap doesn't implement the buffer interface under python 2.")
def test_roundtrip_bytes_mmap(all_types): def test_roundtrip_bytes_mmap(all_types):
msg = all_types.TestAllTypes.new_message() msg = all_types.TestAllTypes.new_message()