Skip to content

Commit

Permalink
Remove NotImplementedError from test_hookable.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Jun 30, 2017
1 parent 75ea47d commit fd05159
Showing 1 changed file with 14 additions and 26 deletions.
40 changes: 14 additions & 26 deletions src/zope/component/tests/test_hookable.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
import unittest

from zope.component.tests import fails_if_called

class HookableTests(unittest.TestCase):

Expand All @@ -24,41 +25,34 @@ def test_ctor_no_func(self):

def test_ctor_simple(self):
from zope.component.hookable import hookable
def foo():
raise NotImplementedError()
foo = fails_if_called(self)
hooked = hookable(foo)
self.assertTrue(hooked.original is foo)
self.assertTrue(hooked.implementation is foo)

def test_ctor_extra_arg(self):
from zope.component.hookable import hookable
def foo():
raise NotImplementedError()
foo = fails_if_called(self)
self.assertRaises(TypeError, hookable, foo, foo)

def test_ctor_extra_arg_miss(self):
from zope.component.hookable import hookable
def foo():
raise NotImplementedError()
foo = fails_if_called(self)
self.assertRaises(TypeError, hookable, foo, nonesuch=foo)

def test_sethook(self):
from zope.component.hookable import hookable
def foo():
raise NotImplementedError()
def bar():
raise NotImplementedError()
foo = fails_if_called(self)
bar = fails_if_called(self)
hooked = hookable(foo)
hooked.sethook(bar)
self.assertTrue(hooked.original is foo)
self.assertTrue(hooked.implementation is bar)

def test_reset(self):
from zope.component.hookable import hookable
def foo():
raise NotImplementedError()
def bar():
raise NotImplementedError()
foo = fails_if_called(self)
bar = fails_if_called(self)
hooked = hookable(foo)
hooked.sethook(bar)
hooked.reset()
Expand All @@ -67,36 +61,30 @@ def bar():

def test_cant_assign_original(self):
from zope.component.hookable import hookable
def foo():
raise NotImplementedError()
def bar():
raise NotImplementedError()
foo = fails_if_called(self)
bar = fails_if_called(self)
hooked = hookable(foo)
with self.assertRaises((TypeError, AttributeError)):
hooked.original = bar

def test_cant_delete_original(self):
from zope.component.hookable import hookable
def foo():
raise NotImplementedError()
foo = fails_if_called(self)
hooked = hookable(foo)
with self.assertRaises((TypeError, AttributeError)):
del hooked.original

def test_cant_assign_implementation(self):
from zope.component.hookable import hookable
def foo():
raise NotImplementedError()
def bar():
raise NotImplementedError()
foo = fails_if_called(self)
bar = fails_if_called(self)
hooked = hookable(foo)
with self.assertRaises((TypeError, AttributeError)):
hooked.implementation = bar

def test_cant_delete_implementation(self):
from zope.component.hookable import hookable
def foo():
raise NotImplementedError()
foo = fails_if_called(self)
hooked = hookable(foo)
with self.assertRaises((TypeError, AttributeError)):
del hooked.implementation
Expand Down

0 comments on commit fd05159

Please sign in to comment.