[pypy-commit] pypy py3.5: fix merge in test_memoryobject.py

rlamy pypy.commits at gmail.com
Mon Jan 2 14:45:03 EST 2017


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5
Changeset: r89313:5fee3be01d9e
Date: 2017-01-02 19:44 +0000
http://bitbucket.org/pypy/pypy/changeset/5fee3be01d9e/

Log:	fix merge in test_memoryobject.py

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
@@ -5,7 +5,7 @@
 from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
 from rpython.rlib.buffer import StringBuffer
 
-only_pypy ="config.option.runappdirect and '__pypy__' not in sys.builtin_module_names" 
+only_pypy ="config.option.runappdirect and '__pypy__' not in sys.builtin_module_names"
 
 class TestMemoryViewObject(BaseApiTest):
     def test_fromobject(self, space, api):
@@ -30,10 +30,10 @@
         o = rffi.charp2str(view.c_buf)
         assert o == 'hello'
         w_mv = api.PyMemoryView_FromBuffer(view)
-        for f in ('format', 'itemsize', 'ndim', 'readonly', 
+        for f in ('format', 'itemsize', 'ndim', 'readonly',
                   'shape', 'strides', 'suboffsets'):
             w_f = space.wrap(f)
-            assert space.eq_w(space.getattr(w_mv, w_f), 
+            assert space.eq_w(space.getattr(w_mv, w_f),
                               space.getattr(w_memoryview, w_f))
 
 class AppTestPyBuffer_FillInfo(AppTestCpythonExtensionBase):
@@ -87,11 +87,6 @@
         assert y.shape == (10,)
         assert len(y) == 10
         assert y[3] == 3
-        s = y[3]
-        assert len(s) == struct.calcsize('i')
-        assert s == struct.pack('i', 3)
-        viewlen = module.test_buffer(arr)
-        assert viewlen == y.itemsize * len(y)
 
     def test_buffer_protocol_capi(self):
         foo = self.import_extension('foo', [
@@ -106,7 +101,7 @@
                     return NULL;
                 vlen = view.len / view.itemsize;
                 PyBuffer_Release(&view);
-                return PyInt_FromLong(vlen);
+                return PyLong_FromLong(vlen);
              """),
             ("test_buffer", "METH_VARARGS",
              """
@@ -114,16 +109,16 @@
                 PyObject* obj = PyTuple_GetItem(args, 0);
                 PyObject* memoryview = PyMemoryView_FromObject(obj);
                 if (memoryview == NULL)
-                    return PyInt_FromLong(-1);
+                    return PyLong_FromLong(-1);
                 view = PyMemoryView_GET_BUFFER(memoryview);
                 Py_DECREF(memoryview);
-                return PyInt_FromLong(view->len / view->itemsize);
+                return PyLong_FromLong(view->len / view->itemsize);
             """)])
         module = self.import_module(name='buffer_test')
         arr = module.PyMyArray(10)
         ten = foo.get_len(arr)
         assert ten == 10
-        ten = foo.get_len('1234567890')
+        ten = foo.get_len(b'1234567890')
         assert ten == 10
         ten = foo.test_buffer(arr)
         assert ten == 10
@@ -145,15 +140,15 @@
         shape, strides = get_buffer_info(arr, ['C_CONTIGUOUS'])
         assert strides[-1] == 8
         dt1 = np.dtype(
-             [('a', 'b'), ('b', 'i'), 
-              ('sub0', np.dtype('b,i')), 
-              ('sub1', np.dtype('b,i')), 
-              ('sub2', np.dtype('b,i')), 
-              ('sub3', np.dtype('b,i')), 
-              ('sub4', np.dtype('b,i')), 
-              ('sub5', np.dtype('b,i')), 
-              ('sub6', np.dtype('b,i')), 
-              ('sub7', np.dtype('b,i')), 
+             [('a', 'b'), ('b', 'i'),
+              ('sub0', np.dtype('b,i')),
+              ('sub1', np.dtype('b,i')),
+              ('sub2', np.dtype('b,i')),
+              ('sub3', np.dtype('b,i')),
+              ('sub4', np.dtype('b,i')),
+              ('sub5', np.dtype('b,i')),
+              ('sub6', np.dtype('b,i')),
+              ('sub7', np.dtype('b,i')),
               ('c', 'i')],
              )
         x = np.arange(dt1.itemsize, dtype='int8').view(dt1)


More information about the pypy-commit mailing list