Fix inspection of classes with inheritance
This commit is contained in:
parent
974885de97
commit
259f94d8e8
@ -103,3 +103,13 @@ class TestTypes(unittest.TestCase):
|
||||
|
||||
assert hasattr(Inner, '_wsme_attributes')
|
||||
assert len(Inner._wsme_attributes) == 1
|
||||
|
||||
def test_inspect_with_inheritance(self):
|
||||
class Parent(object):
|
||||
parent_attribute = int
|
||||
|
||||
class Child(Parent):
|
||||
child_attribute = int
|
||||
|
||||
types.register_type(Child)
|
||||
|
||||
|
@ -93,7 +93,11 @@ def sort_attributes(class_, attributes):
|
||||
names_order = []
|
||||
try:
|
||||
lines = []
|
||||
for line in inspect.getsourcelines(class_)[0]:
|
||||
for cls in inspect.getmro(class_):
|
||||
if cls is object:
|
||||
continue
|
||||
lines[len(lines):] = inspect.getsourcelines(cls)[0]
|
||||
for line in lines:
|
||||
line = line.strip().replace(" ", "")
|
||||
if '=' in line:
|
||||
aname = line[:line.index('=')]
|
||||
|
Loading…
Reference in New Issue
Block a user