test & fix the forced attribute order feature.

This commit is contained in:
Christophe de Vienne
2011-09-20 13:24:19 +02:00
parent 9f9c15cae3
commit 7ccf51bb98
2 changed files with 15 additions and 1 deletions

View File

@@ -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):

View File

@@ -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_):