mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue 23898: Fix inspect.classify_class_attrs() to work with __eq__
Patch by Mike Bayer.
This commit is contained in:
commit
095fb84fc2
3 changed files with 21 additions and 3 deletions
|
@ -888,6 +888,21 @@ class TestClassesAndFunctions(unittest.TestCase):
|
|||
should_find_ga = inspect.Attribute('ham', 'data', Meta, 'spam')
|
||||
self.assertIn(should_find_ga, inspect.classify_class_attrs(VA))
|
||||
|
||||
def test_classify_overrides_bool(self):
|
||||
class NoBool(object):
|
||||
def __eq__(self, other):
|
||||
return NoBool()
|
||||
|
||||
def __bool__(self):
|
||||
raise NotImplementedError(
|
||||
"This object does not specify a boolean value")
|
||||
|
||||
class HasNB(object):
|
||||
dd = NoBool()
|
||||
|
||||
should_find_attr = inspect.Attribute('dd', 'data', HasNB, HasNB.dd)
|
||||
self.assertIn(should_find_attr, inspect.classify_class_attrs(HasNB))
|
||||
|
||||
def test_classify_metaclass_class_attribute(self):
|
||||
class Meta(type):
|
||||
fish = 'slap'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue