[pypy-commit] pypy default: add passing test from py3.5
mattip
pypy.commits at gmail.com
Mon Jan 2 16:59:06 EST 2017
Author: Matti Picus <matti.picus at gmail.com>
Branch:
Changeset: r89322:be6558eb1f0b
Date: 2017-01-02 23:49 +0200
http://bitbucket.org/pypy/pypy/changeset/be6558eb1f0b/
Log: add passing test from py3.5
diff --git a/pypy/module/cpyext/test/test_memoryobject.py b/pypy/module/cpyext/test/test_memoryobject.py
--- a/pypy/module/cpyext/test/test_memoryobject.py
+++ b/pypy/module/cpyext/test/test_memoryobject.py
@@ -36,6 +36,30 @@
assert space.eq_w(space.getattr(w_mv, w_f),
space.getattr(w_memoryview, w_f))
+
+class AppTestPyBuffer_FillInfo(AppTestCpythonExtensionBase):
+ def test_fillWithObject(self):
+ module = self.import_extension('foo', [
+ ("fillinfo", "METH_VARARGS",
+ """
+ Py_buffer buf;
+ PyObject *str = PyBytes_FromString("hello, world.");
+ if (PyBuffer_FillInfo(&buf, str, PyBytes_AsString(str), 13,
+ 0, 0)) {
+ return NULL;
+ }
+
+ /* Get rid of our own reference to the object, but
+ * the Py_buffer should still have a reference.
+ */
+ Py_DECREF(str);
+
+ return PyMemoryView_FromBuffer(&buf);
+ """)])
+ result = module.fillinfo()
+ assert b"hello, world." == result
+ del result
+
class AppTestBufferProtocol(AppTestCpythonExtensionBase):
def test_buffer_protocol_app(self):
import struct
More information about the pypy-commit
mailing list