Skip tests based on python version.

This commit is contained in:
Trevor Highland
2019-01-28 18:09:17 +00:00
parent ed6e39ded0
commit 2a66c2f6bf

View File

@@ -1,4 +1,5 @@
import pytest import pytest
import platform
import capnp import capnp
import os import os
import tempfile import tempfile
@@ -41,17 +42,28 @@ def test_large_read_multiple(test_capnp):
for m in test_capnp.Msg.read_multiple(f): for m in test_capnp.Msg.read_multiple(f):
pass pass
def get_two_adjacent_messages(test_capnp):
def test_large_read_multiple_bytes(test_capnp):
msg1 = test_capnp.Msg.new_message() msg1 = test_capnp.Msg.new_message()
msg1.data = [0x41] * 8192 msg1.data = [0x41] * 8192
m1 = msg1.to_bytes() m1 = msg1.to_bytes()
msg2 = test_capnp.Msg.new_message() msg2 = test_capnp.Msg.new_message()
m2 = msg2.to_bytes() m2 = msg2.to_bytes()
data = m1 + m2 return m1 + m2
def test_large_read_multiple_bytes(test_capnp):
data = get_two_adjacent_messages(test_capnp)
for m in test_capnp.Msg.read_multiple_bytes(data): for m in test_capnp.Msg.read_multiple_bytes(data):
pass pass
@pytest.mark.skipif(platform.python_implementation() == 'PyPy', reason="PyPy memoryview support is limited")
def test_large_read_mutltiple_bytes_memoryview(test_capnp):
data = get_two_adjacent_messages(test_capnp)
for m in test_capnp.Msg.read_multiple_bytes(memoryview(data)): for m in test_capnp.Msg.read_multiple_bytes(memoryview(data)):
pass pass
@pytest.mark.skipif(sys.version_info[0] == 3, reason="Legacy buffer support only for python 2.7")
def test_large_read_mutltiple_bytes_buffer(test_capnp):
data = get_two_adjacent_messages(test_capnp)
for m in test_capnp.Msg.read_multiple_bytes(buffer(data)):
pass