def test_lift_descriptor_new_descriptor(self): unboundattr = UnboundAttribute(Class.descAttr, Class) wrapper_descriptor = DescriptorDecoratorBase(Class.descAttr) new_unboundattr = unboundattr.lift_descriptor(wrapper_descriptor) self.assertEqual(new_unboundattr.descriptor, wrapper_descriptor)
def test_repr_Class(self): unboundattr = UnboundAttribute(Class.descAttr, Class) descrep = repr(Class.descAttr) classrep = repr(Class) self.assertEqual(repr(unboundattr), 'UnboundAttribute(' + descrep + ', ' + classrep + ')')
def test_lift_descriptor_set(self): instance = Class() unboundattr = UnboundAttribute(Class.descAttr, Class) wrapper_descriptor = DescriptorDecoratorBase(Class.descAttr) new_unboundattr = unboundattr.lift_descriptor(wrapper_descriptor) new_unboundattr.set(instance, 5) self.assertEqual(instance.descAttr, 5)
def __get__(self, instance, owner): if instance is None: return UnboundAttribute(self, owner) else: return self._get(instance)
def test_str_AnotherClass(self): unboundattr = UnboundAttribute(AnotherClass.desc, AnotherClass) self.assertEqual(str(unboundattr), "Unbound Attribute 'AnotherClass.desc'")
def test_str_Class(self): unboundattr = UnboundAttribute(Class.descAttr, Class) self.assertEqual(str(unboundattr), "Unbound Attribute 'Class.descAttr'")
def setUp(self): unboundattr = UnboundAttribute(Class.descAttr, Class) self.wrapper_descriptor = DescriptorDecoratorBase(Class.descAttr) self.new_unboundattr = unboundattr.lift_descriptor( self.wrapper_descriptor)
def setUp(self): self.unboundattr = UnboundAttribute(Class.descAttr, Class)