Skip to content

Commit cd67113

Browse files
committed
not all tests pass with cffi on cpython
memoryview(Frame) doesn't work with CFFI
1 parent e3148b8 commit cd67113

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

tests/test_message.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import time
1717

1818
import zmq
19-
from zmq_test_utils import PYPY, BaseZMQTestCase, SkipTest, skip_pypy
19+
from zmq_test_utils import PYPY, BaseZMQTestCase, SkipTest, skip_cpython_cffi, skip_pypy
2020

2121
# some useful constants:
2222

@@ -230,6 +230,7 @@ def test_buffer_out(self):
230230
assert outb is m.buffer
231231
assert m.buffer is m.buffer
232232

233+
@skip_cpython_cffi
233234
def test_memoryview_shape(self):
234235
"""memoryview shape info"""
235236
data = "§§¶•ªº˜µ¬˚…∆˙åß∂©œ∑´†≈ç√".encode()
@@ -278,6 +279,7 @@ def test_memoryview(self):
278279
assert s2 == s
279280
assert m.bytes == s
280281

282+
@skip_cpython_cffi
281283
def test_noncopying_recv(self):
282284
"""check for clobbering message buffers"""
283285
null = b'\0' * 64
@@ -300,6 +302,7 @@ def test_noncopying_recv(self):
300302
assert m2.bytes == ff
301303
assert type(m2.bytes) is bytes
302304

305+
@skip_cpython_cffi
303306
def test_noncopying_memoryview(self):
304307
"""test non-copying memmoryview messages"""
305308
null = b'\0' * 64

tests/test_socket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ def test_large_send(self):
630630
# sample the front and back of the received message
631631
# without checking the whole content
632632
byte = ord(c)
633-
view = memoryview(rcvd)
633+
view = memoryview(rcvd.buffer)
634634
assert len(view) == N
635635
assert view[0] == byte
636636
assert view[-1] == byte

tests/zmq_test_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
have_gevent = False
2828

2929

30-
PYPY = platform.python_implementation() == 'PyPy'
30+
CFFI = zmq.backend.Socket.__module__.startswith("zmq.backend.cffi.")
31+
PYPY = platform.python_implementation() == 'PyPy' or CFFI
3132

3233
# -----------------------------------------------------------------------------
3334
# skip decorators (directly from unittest)
@@ -38,7 +39,11 @@ def _id(x):
3839
return x
3940

4041

41-
skip_pypy = mark.skipif(PYPY, reason="Doesn't work on PyPy")
42+
skip_pypy = mark.skipif(PYPY, reason="Doesn't work on CFFI backend")
43+
skip_cpython_cffi = mark.skipif(
44+
platform.python_implementation() == 'CPython' and CFFI,
45+
reason="CFFI on CPython is unsupported",
46+
)
4247
require_zmq_4 = mark.skipif(zmq.zmq_version_info() < (4,), reason="requires zmq >= 4")
4348

4449
# -----------------------------------------------------------------------------

zmq/sugar/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __repr__(self):
7474
nbytes = len(self)
7575
msg_suffix = ""
7676
if nbytes > 16:
77-
msg_bytes = bytes(memoryview(self)[:12])
77+
msg_bytes = bytes(memoryview(self.buffer)[:12])
7878
if nbytes >= 1e9:
7979
unit = "GB"
8080
n = nbytes // 1e9

0 commit comments

Comments
 (0)