mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Plugin.doc instance attribute is now parsed out using inspect.getdoc(); added Plugin.summary instance attribute, created in Plugin.__init__()
This commit is contained in:
@@ -258,7 +258,11 @@ class Plugin(ReadOnly):
|
|||||||
self.name = cls.__name__
|
self.name = cls.__name__
|
||||||
self.module = cls.__module__
|
self.module = cls.__module__
|
||||||
self.fullname = '%s.%s' % (self.module, self.name)
|
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')
|
log = logging.getLogger('ipa')
|
||||||
for name in ('debug', 'info', 'warning', 'error', 'critical'):
|
for name in ('debug', 'info', 'warning', 'error', 'critical'):
|
||||||
setattr(self, name, getattr(log, name))
|
setattr(self, name, getattr(log, name))
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
Test the `ipalib.plugable` module.
|
Test the `ipalib.plugable` module.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import inspect
|
||||||
from tests.util import raises, no_set, no_del, read_only
|
from tests.util import raises, no_set, no_del, read_only
|
||||||
from tests.util import getitem, setitem, delitem
|
from tests.util import getitem, setitem, delitem
|
||||||
from tests.util import ClassChecker, create_test_api
|
from tests.util import ClassChecker, create_test_api
|
||||||
@@ -313,7 +314,7 @@ class test_Plugin(ClassChecker):
|
|||||||
assert o.name == 'Plugin'
|
assert o.name == 'Plugin'
|
||||||
assert o.module == 'ipalib.plugable'
|
assert o.module == 'ipalib.plugable'
|
||||||
assert o.fullname == 'ipalib.plugable.Plugin'
|
assert o.fullname == 'ipalib.plugable.Plugin'
|
||||||
assert o.doc == self.cls.__doc__
|
assert o.doc == inspect.getdoc(self.cls)
|
||||||
class some_subclass(self.cls):
|
class some_subclass(self.cls):
|
||||||
"""
|
"""
|
||||||
Do sub-classy things.
|
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
|
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
|
company, this class *is* useful as we all need a little sub-class
|
||||||
now and then.
|
now and then.
|
||||||
|
|
||||||
|
One more paragraph.
|
||||||
"""
|
"""
|
||||||
o = some_subclass()
|
o = some_subclass()
|
||||||
assert o.name == 'some_subclass'
|
assert o.name == 'some_subclass'
|
||||||
assert o.module == __name__
|
assert o.module == __name__
|
||||||
assert o.fullname == '%s.some_subclass' % __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):
|
def test_implements(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user