summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipalib/plugable.py16
-rw-r--r--ipalib/tests/test_plugable.py2
2 files changed, 10 insertions, 8 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 57ab8bc7..811a5527 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -192,6 +192,14 @@ class DictProxy(SetProxy):
"""
return self.__d[key]
+ def __call__(self):
+ """
+ Iterates (in ascending order by key) through the values in this
+ container.
+ """
+ for key in self:
+ yield self.__d[key]
+
class MagicDict(DictProxy):
"""
@@ -530,14 +538,6 @@ class NameSpace(DictProxy):
setattr(self, name, member)
yield (name, member)
- def __call__(self):
- """
- Iterates (in ascending order by name) through the members in this
- NameSpace.
- """
- for key in self:
- yield self[key]
-
def __repr__(self):
"""
Returns pseudo-valid Python expression that could be used to construct
diff --git a/ipalib/tests/test_plugable.py b/ipalib/tests/test_plugable.py
index aece3fb8..44067b80 100644
--- a/ipalib/tests/test_plugable.py
+++ b/ipalib/tests/test_plugable.py
@@ -192,6 +192,7 @@ class test_DictProxy(ClassChecker):
# Check initial state
assert len(proxy) == len(target)
assert list(proxy) == sorted(target)
+ assert list(proxy()) == [target[k] for k in sorted(target)]
assert key not in proxy
raises(KeyError, getitem, proxy, key)
@@ -199,6 +200,7 @@ class test_DictProxy(ClassChecker):
target[key] = val
assert len(proxy) == len(target)
assert list(proxy) == sorted(target)
+ assert list(proxy()) == [target[k] for k in sorted(target)]
# Verify TypeError is raised trying to set/del via proxy
raises(TypeError, setitem, proxy, key, val)