Skip to content

Commit

Permalink
Remove NotImplementedError from test_factory.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Jun 30, 2017
1 parent 48e44ab commit 911bb17
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/zope/component/tests/test_factory.py
Expand Up @@ -15,6 +15,7 @@
"""
import unittest

from zope.component.tests import fails_if_called

class FactoryTests(unittest.TestCase):

Expand All @@ -24,7 +25,7 @@ def _getTargetClass(self):

def _makeOne(self, callable=None, *args, **kw):
if callable is None:
callable = _test_callable
callable = fails_if_called(self)
return self._getTargetClass()(callable, *args, **kw)

def test_class_conforms_to_IFactory(self):
Expand All @@ -38,14 +39,15 @@ def test_instance_conforms_to_IFactory(self):
verifyObject(IFactory, self._makeOne())

def test_ctor_defaults(self):
factory = self._makeOne()
self.assertEqual(factory._callable, _test_callable)
func = fails_if_called(self)
factory = self._makeOne(func)
self.assertEqual(factory._callable, func)
self.assertEqual(factory.title, '')
self.assertEqual(factory.description, '')
self.assertEqual(factory._interfaces, None)

def test_ctor_expclit(self):
factory = self._makeOne(_test_callable, 'TITLE', 'DESCRIPTION')
factory = self._makeOne(fails_if_called(self), 'TITLE', 'DESCRIPTION')
self.assertEqual(factory.title, 'TITLE')
self.assertEqual(factory.description, 'DESCRIPTION')

Expand Down Expand Up @@ -82,9 +84,9 @@ class IBar(Interface):
pass
class IBaz(Interface):
pass
@implementer(IBaz)
def _callable():
raise NotImplementedError()
_callable = fails_if_called(self)
_callable.__name__ = '_callable'
_callable = implementer(IBaz)(_callable)
factory = self._makeOne(_callable, interfaces=(IFoo, IBar))
spec = factory.getInterfaces()
self.assertEqual(spec.__name__, '_callable')
Expand All @@ -95,12 +97,7 @@ def test_getInterfaces_implicit(self):
from zope.interface import implementer
class IBaz(Interface):
pass
@implementer(IBaz)
def _callable():
raise NotImplementedError()
_callable = implementer(IBaz)(fails_if_called(self))
factory = self._makeOne(_callable)
spec = factory.getInterfaces()
self.assertEqual(list(spec), [IBaz])

def _test_callable(*args, **kw):
raise NotImplementedError()

0 comments on commit 911bb17

Please sign in to comment.