mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #28214: Now __set_name__ is looked up on the class instead of the
instance.
This commit is contained in:
parent
b00e00c339
commit
afd02a439f
3 changed files with 22 additions and 5 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue