Skip to content

Commit

Permalink
cidict: Make iteration over cidict yield same values as keys()
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Dufresne authored and Petr Viktorin committed Mar 14, 2018
1 parent 60b761b commit 28528ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Lib/ldap/cidict.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def has_key(self,key):
def __contains__(self,key):
return IterableUserDict.__contains__(self, key.lower())

def __iter__(self):
return iter(self.keys())

def keys(self):
return self._keys.values()

Expand Down
2 changes: 2 additions & 0 deletions Tests/t_cidict.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def test_cidict(self):
self.assertEqual(cix.get("xyz", None), 987)
cix_keys = sorted(cix.keys())
self.assertEqual(cix_keys, ['AbCDeF','xYZ'])
cix_keys = sorted(cix)
self.assertEqual(cix_keys, ['AbCDeF','xYZ'])
cix_items = sorted(cix.items())
self.assertEqual(cix_items, [('AbCDeF',123), ('xYZ',987)])
del cix["abcdEF"]
Expand Down

0 comments on commit 28528ea

Please sign in to comment.