Commit 4c089036 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Make this test a bit harder

parent 92c78799
import sys
class C(object): class C(object):
def __delattr__(self, attr): def __delattr__(self, attr):
print "__delattr__" print "__delattr__"
del C.__delattr__ del C.__delattr__
sys._clear_type_cache()
c = C() c = C()
del c.a del c.a
try: try:
...@@ -13,6 +16,7 @@ class C(object): ...@@ -13,6 +16,7 @@ class C(object):
def __getattr__(self, attr): def __getattr__(self, attr):
print "__getattr__" print "__getattr__"
del C.__getattr__ del C.__getattr__
sys._clear_type_cache()
return attr return attr
c = C() c = C()
print c.a print c.a
...@@ -25,9 +29,31 @@ class C(object): ...@@ -25,9 +29,31 @@ class C(object):
def __setattr__(self, attr, val): def __setattr__(self, attr, val):
print "__setattr__", attr, val print "__setattr__", attr, val
del C.__setattr__ del C.__setattr__
sys._clear_type_cache()
c = C() c = C()
c.a = 1 c.a = 1
try: try:
c.a = 2 c.a = 2
except Exception as e: except Exception as e:
print e print e
class D(object):
def __get__(self, obj, type):
print "D.__get__"
del D.__get__
sys._clear_type_cache()
return 1
def __set__(self, obj, value):
print "D.__set__"
del D.__set__
sys._clear_type_cache()
C.x = D()
c = C()
c.x = 0
print c.x
c.x = 0
print c.x
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