Commit 365ee969 authored by Chris Toshok's avatar Chris Toshok

add slot tests for __setattr__ and __delattr__

parent 1d6c5fa4
......@@ -626,6 +626,16 @@ call_funcs(PyObject* _module, PyObject* args) {
printf("tp_getattr doesnt exist\n");
}
// we aren't checking for tp_getattro. it's set in cpython and not in pyston
if (cls->tp_setattr) {
printf("tp_setattr exists\n");
} else {
printf("tp_setattr doesnt exist\n");
}
// we aren't checking for tp_setattro. it's set in cpython and not in pyston
if (cls->tp_as_mapping) {
printf("tp_as_mapping exists\n");
PyMappingMethods* map = cls->tp_as_mapping;
......
......@@ -161,3 +161,53 @@ try:
print c.foo()
except SystemError, e:
print e
print "**** setattr on class def"
class C7(C):
def __setattr__(self, attr, val):
print "setattr", attr, val
c = C7()
slots_test.call_funcs(c)
c.foo = 1
c.bar = 2
c.baz = 3
print "**** setattr set after the fact"
def _setattr_(self, attr, val):
print "_setattr_", attr, val
c = C6()
c.__setattr__ = _setattr_
slots_test.call_funcs(c)
c.foo = 1
c.bar = 2
c.baz = 3
print "**** delattr on class def"
class C8(C):
def __delattr__(self, attr):
print "delattr", attr
c = C8()
slots_test.call_funcs(c)
delattr(c, 'foo')
del c.bar
print "**** delattr set after the fact"
def _delattr_(self, attr):
print "_delattr_", attr
c = C6()
c.__delattr__ = _delattr_
slots_test.call_funcs(c)
try:
delattr(c, 'foo')
except Exception as e:
pass
try:
del c.bar
except Exception as e:
pass
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment