[pypy-commit] pypy cpyext-inheritance: test now passes -A, fails untranslated. Also skip tests based on applevel sys, not host sys
mattip
pypy.commits at gmail.com
Fri Jun 3 08:46:11 EDT 2016
Author: Matti Picus <matti.picus at gmail.com>
Branch: cpyext-inheritance
Changeset: r84898:f9ebd9c81327
Date: 2016-06-03 15:44 +0300
http://bitbucket.org/pypy/pypy/changeset/f9ebd9c81327/
Log: test now passes -A, fails untranslated. Also skip tests based on
applevel sys, not host sys
diff --git a/pypy/module/cpyext/test/foo.c b/pypy/module/cpyext/test/foo.c
--- a/pypy/module/cpyext/test/foo.c
+++ b/pypy/module/cpyext/test/foo.c
@@ -223,6 +223,42 @@
foo_getseters, /*tp_getset*/
};
+static PyTypeObject footypeNoSub = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "foo.fooNoSub", /*tp_name*/
+ sizeof(fooobject), /*tp_size*/
+ 0, /*tp_itemsize*/
+ /* methods */
+ (destructor)foo_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ foo_repr, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ foo_call, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ (setattrofunc)foo_setattro, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ foo_doc, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ foo_methods, /*tp_methods*/
+ foo_members, /*tp_members*/
+ foo_getseters, /*tp_getset*/
+};
+
+
+
/* A type that inherits from 'unicode */
typedef struct {
@@ -664,6 +700,8 @@
if (PyType_Ready(&footype) < 0)
return;
+ if (PyType_Ready(&footypeNoSub) < 0)
+ return;
if (PyType_Ready(&UnicodeSubtype) < 0)
return;
if (PyType_Ready(&UnicodeSubtype2) < 0)
@@ -697,6 +735,8 @@
return;
if (PyDict_SetItemString(d, "fooType", (PyObject *)&footype) < 0)
return;
+ if (PyDict_SetItemString(d, "fooTypeNoSub", (PyObject *)&footypeNoSub) < 0)
+ return;
if (PyDict_SetItemString(d, "UnicodeSubtype", (PyObject *) &UnicodeSubtype) < 0)
return;
if (PyDict_SetItemString(d, "UnicodeSubtype2", (PyObject *) &UnicodeSubtype2) < 0)
diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py
--- a/pypy/module/cpyext/test/test_typeobject.py
+++ b/pypy/module/cpyext/test/test_typeobject.py
@@ -6,7 +6,6 @@
from pypy.module.cpyext.typeobject import PyTypeObjectPtr
import pytest
-import sys
class AppTestTypeObject(AppTestCpythonExtensionBase):
def test_typeobject(self):
@@ -124,8 +123,10 @@
obj = module.fooType.classmeth()
assert obj is module.fooType
- @pytest.mark.skipif('__pypy__' not in sys.builtin_module_names, reason='cpython segfaults')
def test_new(self):
+ import sys
+ if '__pypy__' not in sys.builtin_module_names:
+ skip('cpython segfaults')
# XXX cpython segfaults but if run singly (with -k test_new) this passes
module = self.import_module(name='foo')
obj = module.new()
@@ -196,11 +197,10 @@
del x, y
def test_metaclass_compatible2(self):
- skip('type.__new__ does not check acceptable_as_base_class')
- # XXX FIX - must raise since fooType (which is a base type)
+ # must raise since fooTypeNoSub (which is a base type)
# does not have flag Py_TPFLAGS_BASETYPE
module = self.import_module(name='foo')
- raises(TypeError, module.MetaType, 'other', (module.fooType,), {})
+ raises(TypeError, module.MetaType, 'other', (module.fooTypeNoSub,), {})
def test_sre(self):
import sys
for m in ['_sre', 'sre_compile', 'sre_constants', 'sre_parse', 're']:
@@ -901,8 +901,10 @@
#print('calling module.footype()...')
module.footype("X", (object,), {})
- @pytest.mark.skipif('__pypy__' not in sys.builtin_module_names, reason='cpython fails')
def test_app_subclass_of_c_type(self):
+ import sys
+ if '__pypy__' not in sys.builtin_module_names:
+ skip('cpython adds 6 bytes to size')
# on cpython, the size changes (6 bytes added)
module = self.import_module(name='foo')
size = module.size_of_instances(module.fooType)
More information about the pypy-commit
mailing list