Skip to content

Commit

Permalink
get rid of strange assertRaises helper
Browse files Browse the repository at this point in the history
  • Loading branch information
philikon committed Jun 12, 2005
1 parent 2d16550 commit 8176597
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions tests/test_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,6 @@ def setUp(test):
def tearDown(test):
placelesssetup.tearDown()

def assertRaises(exceptionType, callable, *args):
try:
callable(*args)
return False
except Exception, e:
return isinstance(e, exceptionType)

class TestSetUpWidget(object):

def test_typical(self):
Expand Down Expand Up @@ -202,9 +195,10 @@ def test_validation(self):
>>> view = BrowserView(Content(), request)
>>> setattr(view, 'foo_widget', 'not a widget')
>>> assertRaises(TypeError, setUpWidget,
... view, 'foo', IContent['foo'], IFooWidget)
True
>>> setUpWidget(view, 'foo', IContent['foo'], IFooWidget)
Traceback (most recent call last):
...
TypeError: Unable to configure a widget for foo - attribute foo_widget does not provide IWidget
Similarly, if a view has a widget attribute that implements
IViewFactory, the object created by the factory must implement IWidget.
Expand All @@ -214,9 +208,10 @@ def test_validation(self):
... def __call__(self, request, context):
... return 'not a widget'
>>> setattr(view, 'foo_widget', Factory())
>>> assertRaises(TypeError, setUpWidget,
... view, 'foo', IContent['foo'], IFooWidget)
True
>>> setUpWidget(view, 'foo', IContent['foo'], IFooWidget)
Traceback (most recent call last):
...
TypeError: Unable to configure a widget for foo - attribute foo_widget does not provide IWidget
"""

def test_context(self):
Expand Down Expand Up @@ -287,9 +282,11 @@ def test_widgetLookup(self):
>>> class IUnregisteredWidget(IWidget):
... pass
>>> delattr(view, 'foo_widget')
>>> assertRaises(ComponentLookupError, setUpWidget,
... view, 'foo', IContent['foo'], IUnregisteredWidget)
True
>>> setUpWidget(view, 'foo', IContent['foo'],
... IUnregisteredWidget) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
ComponentLookupError: ...
"""

def test_prefix(self):
Expand Down

0 comments on commit 8176597

Please sign in to comment.