156: Fixed all broken docstring cross references

This commit is contained in:
Jason Gerard DeRose 2008-08-14 08:28:48 +00:00
parent 8c27f4c2de
commit f0dfb9f873
4 changed files with 59 additions and 45 deletions

View File

@ -182,13 +182,19 @@ class Plugin(ReadOnly):
@classmethod @classmethod
def implemented_by(cls, arg): def implemented_by(cls, arg):
""" """
Returns True if (1) `arg` is an instance of or subclass of this class, Returns True if.
and (2) `arg` (or `arg.__class__` if instance) has an attribute for
each name in this class's __public__ frozenset; returns False
otherwise.
Unlike ProxyTarget.implements(), this returns a concrete answer 1. ``arg`` is an instance of or subclass of this class, and
because the attributes of the subclass are checked.
2. ``arg`` (or ``arg.__class__`` if instance) has an attribute for
each name in this class's ``__public__`` frozenset
Otherwise, returns False.
Unlike `Plugin.implements`, this returns a concrete answer because
the attributes of the subclass are checked.
:param arg: An instance of or subclass of this class.
""" """
if inspect.isclass(arg): if inspect.isclass(arg):
subclass = arg subclass = arg
@ -465,8 +471,8 @@ class NameSpace(ReadOnly):
class Registrar(ReadOnly): class Registrar(ReadOnly):
def __init__(self, *allowed): def __init__(self, *allowed):
""" """
`*allowed` is a list of the base classes plugins can be subclassed :param *allowed: Base classes from which plugins accepted by this
from. Registrar must subclass.
""" """
self.__allowed = frozenset(allowed) self.__allowed = frozenset(allowed)
self.__d = {} self.__d = {}
@ -480,8 +486,8 @@ class Registrar(ReadOnly):
def __findbase(self, cls): def __findbase(self, cls):
""" """
If `cls` is a subclass of a base in self.__allowed, returns that If ``cls`` is a subclass of a base in self.__allowed, returns that
base; otherwise raises SubclassError. base; otherwise raises `errors.SubclassError`.
""" """
assert inspect.isclass(cls) assert inspect.isclass(cls)
found = False found = False
@ -494,7 +500,7 @@ class Registrar(ReadOnly):
def __call__(self, cls, override=False): def __call__(self, cls, override=False):
""" """
Register the plugin `cls`. Register the plugin ``cls``.
""" """
if not inspect.isclass(cls): if not inspect.isclass(cls):
raise TypeError('plugin must be a class: %r' % cls) raise TypeError('plugin must be a class: %r' % cls)
@ -525,7 +531,8 @@ class Registrar(ReadOnly):
def __getitem__(self, item): def __getitem__(self, item):
""" """
Returns a copy of the namespace dict of the base class named `name`. Returns a copy of the namespace dict of the base class named
``name``.
""" """
if inspect.isclass(item): if inspect.isclass(item):
if item not in self.__allowed: if item not in self.__allowed:
@ -537,7 +544,7 @@ class Registrar(ReadOnly):
def __contains__(self, item): def __contains__(self, item):
""" """
Returns True if a base class named `name` is in this Registrar. Returns True if a base class named ``name`` is in this Registrar.
""" """
if inspect.isclass(item): if inspect.isclass(item):
return item in self.__allowed return item in self.__allowed

View File

@ -26,12 +26,18 @@ from ipalib import cli, plugable
def test_to_cli(): def test_to_cli():
"""
Tests the `cli.to_cli` function.
"""
f = cli.to_cli f = cli.to_cli
assert f('initialize') == 'initialize' assert f('initialize') == 'initialize'
assert f('user_add') == 'user-add' assert f('user_add') == 'user-add'
def test_from_cli(): def test_from_cli():
"""
Tests the `cli.from_cli` function.
"""
f = cli.from_cli f = cli.from_cli
assert f('initialize') == 'initialize' assert f('initialize') == 'initialize'
assert f('user-add') == 'user_add' assert f('user-add') == 'user_add'
@ -71,7 +77,7 @@ class DummyAPI(object):
class test_CLI(ClassChecker): class test_CLI(ClassChecker):
""" """
Tests the `CLI` class. Tests the `cli.CLI` class.
""" """
_cls = cli.CLI _cls = cli.CLI
@ -80,7 +86,7 @@ class test_CLI(ClassChecker):
def test_api(self): def test_api(self):
""" """
Tests the `api` property. Tests the `cli.CLI.api` property.
""" """
api = 'the plugable.API instance' api = 'the plugable.API instance'
o = self.cls(api) o = self.cls(api)
@ -88,7 +94,7 @@ class test_CLI(ClassChecker):
def test_parse(self): def test_parse(self):
""" """
Tests the `parse` method. Tests the `cli.CLI.parse` method.
""" """
o = self.cls(None) o = self.cls(None)
args = ['hello', 'naughty', 'nurse'] args = ['hello', 'naughty', 'nurse']
@ -104,7 +110,7 @@ class test_CLI(ClassChecker):
def test_mcl(self): def test_mcl(self):
""" """
Tests the `mcl` (Max Command Length) property . Tests the `cli.CLI.mcl` (Max Command Length) property .
""" """
cnt = 100 cnt = 100
api = DummyAPI(cnt) api = DummyAPI(cnt)
@ -116,7 +122,7 @@ class test_CLI(ClassChecker):
def test_dict(self): def test_dict(self):
""" """
Tests the `__contains__` and `__getitem__` methods. Tests the `cli.CLI.__contains__` and `cli.CLI.__getitem__` methods.
""" """
cnt = 25 cnt = 25
api = DummyAPI(cnt) api = DummyAPI(cnt)

View File

@ -28,7 +28,7 @@ from ipalib import plugable, errors
class test_ReadOnly(ClassChecker): class test_ReadOnly(ClassChecker):
""" """
Test the `ReadOnly` class Test the `plugable.ReadOnly` class
""" """
_cls = plugable.ReadOnly _cls = plugable.ReadOnly
@ -39,7 +39,8 @@ class test_ReadOnly(ClassChecker):
def test_lock(self): def test_lock(self):
""" """
Tests the `__lock__` and `__islocked__` methods. Tests the `plugable.ReadOnly.__lock__` and
`plugable.ReadOnly.__islocked__` methods.
""" """
o = self.cls() o = self.cls()
assert o.__islocked__() is False assert o.__islocked__() is False
@ -88,7 +89,7 @@ class test_ReadOnly(ClassChecker):
class test_Plugin(ClassChecker): class test_Plugin(ClassChecker):
""" """
Tests the `Plugin` class. Tests the `plugable.Plugin` class.
""" """
_cls = plugable.Plugin _cls = plugable.Plugin
@ -101,7 +102,7 @@ class test_Plugin(ClassChecker):
def test_name(self): def test_name(self):
""" """
Tests the `name` property. Tests the `plugable.Plugin.name` property.
""" """
assert read_only(self.cls(), 'name') == 'Plugin' assert read_only(self.cls(), 'name') == 'Plugin'
@ -111,7 +112,7 @@ class test_Plugin(ClassChecker):
def test_doc(self): def test_doc(self):
""" """
Tests the `doc` property. Tests the `plugable.Plugin.doc` property.
""" """
class some_subclass(self.cls): class some_subclass(self.cls):
'here is the doc string' 'here is the doc string'
@ -119,7 +120,7 @@ class test_Plugin(ClassChecker):
def test_implements(self): def test_implements(self):
""" """
Tests the `implements` classmethod. Tests the `plugable.Plugin.implements` classmethod.
""" """
class example(self.cls): class example(self.cls):
__public__ = frozenset(( __public__ = frozenset((
@ -168,7 +169,7 @@ class test_Plugin(ClassChecker):
def test_implemented_by(self): def test_implemented_by(self):
""" """
Tests the `implemented_by` classmethod. Tests the `plugable.Plugin.implemented_by` classmethod.
""" """
class base(self.cls): class base(self.cls):
__public__ = frozenset(( __public__ = frozenset((
@ -211,7 +212,7 @@ class test_Plugin(ClassChecker):
def test_finalize(self): def test_finalize(self):
""" """
Tests the `finalize` method. Tests the `plugable.Plugin.finalize` method.
""" """
api = 'the api instance' api = 'the api instance'
o = self.cls() o = self.cls()
@ -237,7 +238,7 @@ class test_Plugin(ClassChecker):
class test_Proxy(ClassChecker): class test_Proxy(ClassChecker):
""" """
Tests the `Proxy` class. Tests the `plugable.Proxy` class.
""" """
_cls = plugable.Proxy _cls = plugable.Proxy
@ -309,7 +310,7 @@ class test_Proxy(ClassChecker):
def test_implements(self): def test_implements(self):
""" """
Tests the `implements` method. Tests the `plugable.Proxy.implements` method.
""" """
class base(object): class base(object):
__public__ = frozenset() __public__ = frozenset()
@ -334,7 +335,7 @@ class test_Proxy(ClassChecker):
def test_clone(self): def test_clone(self):
""" """
Tests the `__clone__` method. Tests the `plugable.Proxy.__clone__` method.
""" """
class base(object): class base(object):
__public__ = frozenset() __public__ = frozenset()
@ -353,7 +354,7 @@ class test_Proxy(ClassChecker):
def test_check_name(): def test_check_name():
""" """
Tests the `check_name` function. Tests the `plugable.check_name` function.
""" """
f = plugable.check_name f = plugable.check_name
okay = [ okay = [
@ -380,7 +381,7 @@ def test_check_name():
class test_NameSpace(ClassChecker): class test_NameSpace(ClassChecker):
""" """
Tests the `NameSpace` class. Tests the `plugable.NameSpace` class.
""" """
_cls = plugable.NameSpace _cls = plugable.NameSpace

View File

@ -65,7 +65,7 @@ def test_is_rule():
class test_option(ClassChecker): class test_option(ClassChecker):
""" """
Tests the option class. Tests the `public.option` class.
""" """
_cls = public.option _cls = public.option
@ -96,7 +96,7 @@ class test_option(ClassChecker):
def test_normalize(self): def test_normalize(self):
""" """
Tests the `normalize` method. Tests the `public.option.normalize` method.
""" """
assert 'normalize' in self.cls.__public__ assert 'normalize' in self.cls.__public__
o = self.subcls() o = self.subcls()
@ -128,7 +128,7 @@ class test_option(ClassChecker):
def test_validate(self): def test_validate(self):
""" """
Tests the `validate` method. Tests the `public.option.validate` method.
""" """
assert 'validate' in self.cls.__public__ assert 'validate' in self.cls.__public__
o = self.subcls() o = self.subcls()
@ -140,7 +140,7 @@ class test_option(ClassChecker):
def test_rules(self): def test_rules(self):
""" """
Tests the `rules` property. Tests the `public.option.rules` property.
""" """
o = self.subcls() o = self.subcls()
assert len(o.rules) == 3 assert len(o.rules) == 3
@ -151,7 +151,7 @@ class test_option(ClassChecker):
def test_default(self): def test_default(self):
""" """
Tests the `default` method. Tests the `public.option.default` method.
""" """
assert 'default' in self.cls.__public__ assert 'default' in self.cls.__public__
assert self.cls().default() is None assert self.cls().default() is None
@ -159,7 +159,7 @@ class test_option(ClassChecker):
class test_cmd(ClassChecker): class test_cmd(ClassChecker):
""" """
Tests the `cmd` class. Tests the `public.cmd` class.
""" """
_cls = public.cmd _cls = public.cmd
@ -188,7 +188,7 @@ class test_cmd(ClassChecker):
def test_get_options(self): def test_get_options(self):
""" """
Tests the `get_options` method. Tests the `public.cmd.get_options` method.
""" """
assert list(self.cls().get_options()) == [] assert list(self.cls().get_options()) == []
sub = self.subcls() sub = self.subcls()
@ -200,7 +200,7 @@ class test_cmd(ClassChecker):
def test_options(self): def test_options(self):
""" """
Tests the `options` property. Tests the `public.cmd.options` property.
""" """
assert 'options' in self.cls.__public__ # Public assert 'options' in self.cls.__public__ # Public
sub = self.subcls() sub = self.subcls()
@ -216,7 +216,7 @@ class test_cmd(ClassChecker):
def test_normalize(self): def test_normalize(self):
""" """
Tests the `normalize` method. Tests the `public.cmd.normalize` method.
""" """
assert 'normalize' in self.cls.__public__ # Public assert 'normalize' in self.cls.__public__ # Public
kw = dict( kw = dict(
@ -230,7 +230,7 @@ class test_cmd(ClassChecker):
def test_default(self): def test_default(self):
""" """
Tests the `default` method. Tests the `public.cmd.default` method.
""" """
assert 'default' in self.cls.__public__ # Public assert 'default' in self.cls.__public__ # Public
no_fill = dict( no_fill = dict(
@ -251,7 +251,7 @@ class test_cmd(ClassChecker):
def test_validate(self): def test_validate(self):
""" """
Tests the `validate` method. Tests the `public.cmd.validate` method.
""" """
assert 'validate' in self.cls.__public__ # Public assert 'validate' in self.cls.__public__ # Public
@ -281,7 +281,7 @@ class test_cmd(ClassChecker):
def test_execute(self): def test_execute(self):
""" """
Tests the `execute` method. Tests the `public.cmd.execute` method.
""" """
assert 'execute' in self.cls.__public__ # Public assert 'execute' in self.cls.__public__ # Public
@ -317,7 +317,7 @@ def test_attr():
class test_mthd(ClassChecker): class test_mthd(ClassChecker):
""" """
Tests the `mthd` class. Tests the `public.mthd` class.
""" """
_cls = public.mthd _cls = public.mthd
@ -351,7 +351,7 @@ class test_mthd(ClassChecker):
def test_get_options(self): def test_get_options(self):
""" """
Tests the `get_options` method. Tests the `public.mthd.get_options` method.
""" """
sub = self.subcls() sub = self.subcls()
names = ('option0', 'option1', 'prop0', 'prop1') names = ('option0', 'option1', 'prop0', 'prop1')