Skip to content

Commit

Permalink
Make the notify function return its event argument.
Browse files Browse the repository at this point in the history
This facilitates testing and higher-level APIs such as those found in
zope.lifecycleevent. It was proposed in zopefoundation/zope.lifecycleevent#11.
  • Loading branch information
jamadden committed Jul 4, 2017
1 parent fdcfa0d commit 54ed7b5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

- Drop support for Python 3.3.

- Make the ``notify`` function return its event argument. This
facilitates testing and higher-level APIs such as those found in
`zope.lifecycleevent <https://github.com/zopefoundation/zope.lifecycleevent/issues/11>`_.


4.2.0 (2016-02-17)
==================
Expand Down
1 change: 1 addition & 0 deletions src/zope/event/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ def notify(event):
"""
for subscriber in subscribers:
subscriber(event)
return event
2 changes: 1 addition & 1 deletion src/zope/event/classhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
new-style event classes are supported, and then by order of registry.
>>> import zope.event
>>> zope.event.notify(MySubEvent())
>>> _ = zope.event.notify(MySubEvent())
handler3 MySubEvent
handler1 MySubEvent
handler2 MySubEvent
Expand Down
6 changes: 5 additions & 1 deletion src/zope/event/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def tearDown(self):

def _callFUT(self, event):
from zope.event import notify
notify(event)
return notify(event)

def test_empty(self):
event = object()
Expand All @@ -43,6 +43,10 @@ def test_not_empty(self):
self._callFUT(event)
self.assertEqual(dummy, [event])

def test_returns_argument(self):
result = self._callFUT(self)
self.assertIs(result, self)

def setUpClassHandlers(test):
import zope.event
test.globs['old_subs'] = zope.event.subscribers
Expand Down

0 comments on commit 54ed7b5

Please sign in to comment.