diff --git a/wsme/tests/test_types.py b/wsme/tests/test_types.py index 87d66bc..26d7014 100644 --- a/wsme/tests/test_types.py +++ b/wsme/tests/test_types.py @@ -32,6 +32,20 @@ class TestTypes(unittest.TestCase): assert len(WithPrivateAttrs._wsme_attributes) == 0 + def test_attribute_order(self): + class ForcedOrder(object): + _wsme_attr_order = ('a2', 'a1', 'a3') + a1 = int + a2 = int + a3 = int + + types.register_type(ForcedOrder) + + print ForcedOrder._wsme_attributes + assert ForcedOrder._wsme_attributes[0][0] == 'a2' + assert ForcedOrder._wsme_attributes[1][0] == 'a1' + assert ForcedOrder._wsme_attributes[2][0] == 'a3' + def test_wsproperty(self): class WithWSProp(object): def __init__(self): diff --git a/wsme/types.py b/wsme/types.py index d83d5f5..44a38d8 100644 --- a/wsme/types.py +++ b/wsme/types.py @@ -69,7 +69,7 @@ def sort_attributes(class_, attributes): names_order = list(names) names_order.sort() - attributes[:] = [(name, attrs[name]) for name in names_order] + attributes[:] = [(name, attrs[name]) for name in names_order] def inspect_class(class_):