diff --git a/wsme/tests/test_types.py b/wsme/tests/test_types.py index 3ccb1a5..12822f1 100644 --- a/wsme/tests/test_types.py +++ b/wsme/tests/test_types.py @@ -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) + diff --git a/wsme/types.py b/wsme/types.py index 3727daf..3306f96 100644 --- a/wsme/types.py +++ b/wsme/types.py @@ -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('=')]