Issue #28214: Now __set_name__ is looked up on the class instead of the

instance.
This commit is contained in:
Serhiy Storchaka 2016-09-21 15:54:59 +03:00
parent b00e00c339
commit afd02a439f
3 changed files with 22 additions and 5 deletions

View file

@ -148,6 +148,18 @@ class Test(unittest.TestCase):
class A:
d = Descriptor()
def test_set_name_lookup(self):
resolved = []
class NonDescriptor:
def __getattr__(self, name):
resolved.append(name)
class A:
d = NonDescriptor()
self.assertNotIn('__set_name__', resolved,
'__set_name__ is looked up in instance dict')
def test_set_name_init_subclass(self):
class Descriptor:
def __set_name__(self, owner, name):