Skip to content

Commit

Permalink
Fix UpdateNotCalled being an instance
Browse files Browse the repository at this point in the history
  • Loading branch information
mgedmin committed Oct 17, 2017
1 parent 9733e4f commit 1681255
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Expand Up @@ -5,7 +5,8 @@
4.1.1 (unreleased)
==================

- Nothing changed yet.
- Fixed UpdateNotCalled being an instance rather than an exception class
(https://github.com/zopefoundation/zope.contentprovider/issues/4).


4.1.0 (2017-08-08)
Expand Down
8 changes: 4 additions & 4 deletions src/zope/contentprovider/interfaces.py
Expand Up @@ -29,10 +29,10 @@ class IUpdateNotCalled(zope.interface.common.interfaces.IRuntimeError):
"""

class UpdateNotCalled(RuntimeError):
pass

# Make it a singelton
UpdateNotCalled = UpdateNotCalled('``update()`` was not called yet.')
def __init__(self, *args):
if not args:
args = ('``update()`` was not called yet.',)
super(UpdateNotCalled, self).__init__(*args)

class IBeforeUpdateEvent(IObjectEvent):

Expand Down
19 changes: 16 additions & 3 deletions src/zope/contentprovider/tests.py
Expand Up @@ -20,6 +20,17 @@

from zope.component import eventtesting
from zope.testing import cleanup, renormalizing
from zope.contentprovider.interfaces import UpdateNotCalled


class TestExceptionHandling(unittest.TestCase):

def test(self):
try:
raise UpdateNotCalled
except UpdateNotCalled:
pass


counter = 0
mtime_func = None
Expand Down Expand Up @@ -62,14 +73,16 @@ def tearDown(test):
global counter
counter = 0


def test_suite():
return unittest.TestSuite((
return unittest.TestSuite([
unittest.defaultTestLoader.loadTestsFromName(__name__),
doctest.DocFileSuite(
'README.rst',
setUp=setUp, tearDown=tearDown,
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS,
checker=checker,
globs={'__file__': os.path.join(
os.path.dirname(__file__), 'README.rst')}
),
))
])

0 comments on commit 1681255

Please sign in to comment.