summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-12-17 23:08:52 -0700
committerJason Gerard DeRose <jderose@redhat.com>2008-12-17 23:08:52 -0700
commit4f24f0fd8837383f4a2abc54946f6f84810807b8 (patch)
treefe210ce86abd11f693a628ff4f4fd43250fd77df
parent171ed58367e58c59f9f67ef831f08ce80ba8508b (diff)
downloadfreeipa-4f24f0fd8837383f4a2abc54946f6f84810807b8.tar.gz
freeipa-4f24f0fd8837383f4a2abc54946f6f84810807b8.tar.xz
freeipa-4f24f0fd8837383f4a2abc54946f6f84810807b8.zip
Plugin.doc instance attribute is now parsed out using inspect.getdoc(); added Plugin.summary instance attribute, created in Plugin.__init__()
-rw-r--r--ipalib/plugable.py6
-rw-r--r--tests/test_ipalib/test_plugable.py13
2 files changed, 16 insertions, 3 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 5363a51e9..e6b5c1ac8 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -258,7 +258,11 @@ class Plugin(ReadOnly):
self.name = cls.__name__
self.module = cls.__module__
self.fullname = '%s.%s' % (self.module, self.name)
- self.doc = cls.__doc__
+ self.doc = inspect.getdoc(cls)
+ if self.doc is None:
+ self.summary = '<%s>' % self.fullname
+ else:
+ self.summary = self.doc.split('\n\n', 1)[0]
log = logging.getLogger('ipa')
for name in ('debug', 'info', 'warning', 'error', 'critical'):
setattr(self, name, getattr(log, name))
diff --git a/tests/test_ipalib/test_plugable.py b/tests/test_ipalib/test_plugable.py
index 02df058b8..21c712809 100644
--- a/tests/test_ipalib/test_plugable.py
+++ b/tests/test_ipalib/test_plugable.py
@@ -21,6 +21,7 @@
Test the `ipalib.plugable` module.
"""
+import inspect
from tests.util import raises, no_set, no_del, read_only
from tests.util import getitem, setitem, delitem
from tests.util import ClassChecker, create_test_api
@@ -313,7 +314,7 @@ class test_Plugin(ClassChecker):
assert o.name == 'Plugin'
assert o.module == 'ipalib.plugable'
assert o.fullname == 'ipalib.plugable.Plugin'
- assert o.doc == self.cls.__doc__
+ assert o.doc == inspect.getdoc(self.cls)
class some_subclass(self.cls):
"""
Do sub-classy things.
@@ -321,12 +322,20 @@ class test_Plugin(ClassChecker):
Although it doesn't know how to comport itself and is not for mixed
company, this class *is* useful as we all need a little sub-class
now and then.
+
+ One more paragraph.
"""
o = some_subclass()
assert o.name == 'some_subclass'
assert o.module == __name__
assert o.fullname == '%s.some_subclass' % __name__
- assert o.doc == some_subclass.__doc__
+ assert o.doc == inspect.getdoc(some_subclass)
+ assert o.summary == 'Do sub-classy things.'
+ class another_subclass(self.cls):
+ pass
+ o = another_subclass()
+ assert o.doc is None
+ assert o.summary == '<%s>' % o.fullname
def test_implements(self):
"""