From ab4e7b9befb1b84deedfcb29766e8250113ba566 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 3 Dec 2009 23:06:20 +0000 Subject: - ``repoze.bfg.testing.DummyModel`` now accepts a new constructor keyword argument: ``__provides__``. If this constructor argument is provided, it should be an interface or a tuple of interfaces. The resulting model will then provide these interfaces (they will be attached to the constructed model via ``zope.interface.alsoProvides``). --- repoze/bfg/testing.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'repoze/bfg/testing.py') diff --git a/repoze/bfg/testing.py b/repoze/bfg/testing.py index 9638fc21c..127f54283 100644 --- a/repoze/bfg/testing.py +++ b/repoze/bfg/testing.py @@ -8,6 +8,7 @@ from zope.deprecation import deprecated from zope.interface import implements from zope.interface import Interface +from zope.interface import alsoProvides from repoze.bfg.interfaces import IAuthenticationPolicy from repoze.bfg.interfaces import IAuthorizationPolicy @@ -387,13 +388,19 @@ class DummyModel: to the constructor will be used as the ``__name__`` attribute of the model. the value of ``parent`` will be used as the ``__parent__`` attribute of the model. """ - def __init__(self, __name__=None, __parent__=None, **kw): + def __init__(self, __name__=None, __parent__=None, __provides__=None, + **kw): """ The he model's ``__name__`` attribute will be set to the value of ``__name__``, and the model's ``__parent__`` - attribute will be set to the value of ``__parent__``. Any + attribute will be set to the value of ``__parent__``. If + ``__provides__`` is specified, it should be an interface + object or tuple of interface objects that will be attached to + the resulting model via ``zope.interface.alsoProvides``. Any extra keywords will be set as direct attributes of the model.""" self.__name__ = __name__ self.__parent__ = __parent__ + if __provides__ is not None: + alsoProvides(self, __provides__) self.kw = kw self.__dict__.update(**kw) self.subs = {} -- cgit v1.2.3