From 79983c078f77957ffe2c9f81352d89afbcc4e593 Mon Sep 17 00:00:00 2001 From: kakwa Date: Sat, 9 Feb 2019 16:22:42 +0100 Subject: [PATCH] fix behavior of get_attributes() * make sure it returns an ordered list in both python 2 and python 3 --- ldapcherry/attributes.py | 4 +++- tests/test_Attributes.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ldapcherry/attributes.py b/ldapcherry/attributes.py index 989bf14..5ddea82 100644 --- a/ldapcherry/attributes.py +++ b/ldapcherry/attributes.py @@ -130,7 +130,9 @@ class Attributes: def get_backend_attributes(self, backend): if backend not in self.backends: raise WrongBackend(backend) - return self.backend_attributes[backend].keys() + ret = list(self.backend_attributes[backend].keys()) + ret.sort() + return ret def get_backend_key(self, backend): if backend not in self.backends: diff --git a/tests/test_Attributes.py b/tests/test_Attributes.py index f7f42b2..aab7342 100644 --- a/tests/test_Attributes.py +++ b/tests/test_Attributes.py @@ -42,6 +42,7 @@ class TestError(object): inv = Attributes('./tests/cfg/attributes.yml') ret = inv.get_backend_attributes('ldap') expected = ['shell', 'cn', 'userPassword', 'uidNumber', 'gidNumber', 'sn', 'home', 'givenName', 'email', 'uid'] + expected.sort() assert ret == expected def testGetKey(self):