def test_w_factory_returning_spec(self):
from zope.interface import Interface
from zope.interface import implementer
from zope.interface import providedBy
from guillotina.component.interfaces import IFactory
class IFoo(Interface):
pass
class IBar(Interface):
pass
@implementer(IFoo, IBar)
class _Factory(object):
def get_interfaces(self):
return providedBy(self)
_factory = _Factory()
class Context(object):
def __conform__(self, iface):
return self
def getUtilitiesFor(self, iface):
if iface is IFactory:
return [('test', _factory)]
self.assertEqual(list(self._callFUT(IFoo, context=Context())),
[('test', _factory)])
self.assertEqual(list(self._callFUT(IBar, context=Context())),
[('test', _factory)])
评论列表
文章目录