summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipalib/plugable.py7
-rw-r--r--ipalib/tests/test_plugable.py17
2 files changed, 21 insertions, 3 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 581f377b4..c5ceeffe2 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -76,6 +76,13 @@ class ReadOnly(object):
class ProxyTarget(ReadOnly):
__public__ = frozenset()
+ def __get_name(self):
+ """
+ Convenience property to return the class name.
+ """
+ return self.__class__.__name__
+ name = property(__get_name)
+
@classmethod
def implements(cls, arg):
assert type(cls.__public__) is frozenset
diff --git a/ipalib/tests/test_plugable.py b/ipalib/tests/test_plugable.py
index c3245e775..25f520993 100644
--- a/ipalib/tests/test_plugable.py
+++ b/ipalib/tests/test_plugable.py
@@ -55,7 +55,7 @@ def test_valid_identifier():
class test_ReadOnly(ClassChecker):
"""
- Test the plugable.ReadOnly class
+ Test the `ReadOnly` class
"""
_cls = plugable.ReadOnly
@@ -103,17 +103,28 @@ class test_ReadOnly(ClassChecker):
class test_ProxyTarget(ClassChecker):
"""
- Test the plugable.ProxyTarget class.
+ Test the `ProxyTarget` class.
"""
_cls = plugable.ProxyTarget
def test_class(self):
assert self.cls.__bases__ == (plugable.ReadOnly,)
+ assert type(self.cls.name) is property
assert self.cls.implements(frozenset())
+ def test_name(self):
+ """
+ Test the `name` property.
+ """
+ assert read_only(self.cls(), 'name') == 'ProxyTarget'
+
+ class some_subclass(self.cls):
+ pass
+ assert read_only(some_subclass(), 'name') == 'some_subclass'
+
def test_implements(self):
"""
- Test the implements() classmethod
+ Test the `implements` classmethod.
"""
class example(self.cls):
__public__ = frozenset((