def test_delete(self): f = Field(name="NAME") instance = Typing2() f.direct_set(instance, 10) self.assertEqual(instance._NAME, 10) f.__delete__(instance) self.assertEqual(getattr(instance, "_NAME", "DONOTEXIST"), "DONOTEXIST")
def test_set(self): f = Field(name="NAME") def func1(instance, value): return value + 10 f.setters(func1) f.setters(func1) instance = Typing2() f.direct_set(instance, 10) self.assertEqual(instance._NAME, 10) f.__set__(instance, 40) self.assertEqual(instance._NAME, 60) f.setters(clear=True) f.__set__(instance, 40) self.assertEqual(instance._NAME, 40)