Merge pull request #417 from kuba/plugins

Plugins fixes (unhashable PluginEntryPoint, typo in examples)
This commit is contained in:
James Kasten 2015-05-18 11:22:04 -07:00
commit 1ada2cab15
3 changed files with 6 additions and 4 deletions

View file

@ -20,7 +20,7 @@ class Authenticator(common.Plugin):
# "self" as first argument, e.g. def prepare(self)...
class Installer(common.Plugins):
class Installer(common.Plugin):
"""Example Installer."""
zope.interface.implements(interfaces.IInstaller)
zope.interface.classProvides(interfaces.IPluginFactory)

View file

@ -215,8 +215,9 @@ class PluginsRegistry(collections.Mapping):
return None
def __repr__(self):
return "{0}({1!r})".format(
self.__class__.__name__, set(self._plugins.itervalues()))
return "{0}({1})".format(
self.__class__.__name__, ','.join(
repr(p_ep) for p_ep in self._plugins.itervalues()))
def __str__(self):
if not self._plugins:

View file

@ -154,6 +154,7 @@ class PluginsRegistryTest(unittest.TestCase):
def setUp(self):
from letsencrypt.plugins.disco import PluginsRegistry
self.plugin_ep = mock.MagicMock(name="mock")
self.plugin_ep.__hash__.side_effect = TypeError
self.plugins = {"mock": self.plugin_ep}
self.reg = PluginsRegistry(self.plugins)
@ -227,7 +228,7 @@ class PluginsRegistryTest(unittest.TestCase):
def test_repr(self):
self.plugin_ep.__repr__ = lambda _: "PluginEntryPoint#mock"
self.assertEqual("PluginsRegistry(set([PluginEntryPoint#mock]))",
self.assertEqual("PluginsRegistry(PluginEntryPoint#mock)",
repr(self.reg))
def test_str(self):