Skip to content

Commit 28528ea

Browse files
jdufresneencukou
authored andcommitted
cidict: Make iteration over cidict yield same values as keys()
1 parent 60b761b commit 28528ea

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Lib/ldap/cidict.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ def has_key(self,key):
4444
def __contains__(self,key):
4545
return IterableUserDict.__contains__(self, key.lower())
4646

47+
def __iter__(self):
48+
return iter(self.keys())
49+
4750
def keys(self):
4851
return self._keys.values()
4952

Tests/t_cidict.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def test_cidict(self):
3636
self.assertEqual(cix.get("xyz", None), 987)
3737
cix_keys = sorted(cix.keys())
3838
self.assertEqual(cix_keys, ['AbCDeF','xYZ'])
39+
cix_keys = sorted(cix)
40+
self.assertEqual(cix_keys, ['AbCDeF','xYZ'])
3941
cix_items = sorted(cix.items())
4042
self.assertEqual(cix_items, [('AbCDeF',123), ('xYZ',987)])
4143
del cix["abcdEF"]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy