summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.rst4
-rw-r--r--src/zope/event/__init__.py1
-rw-r--r--src/zope/event/classhandler.py2
-rw-r--r--src/zope/event/tests.py6
4 files changed, 11 insertions, 2 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index c3b3176..da82dac 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -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)
==================
diff --git a/src/zope/event/__init__.py b/src/zope/event/__init__.py
index 8eaf9bf..ae3a2c0 100644
--- a/src/zope/event/__init__.py
+++ b/src/zope/event/__init__.py
@@ -30,3 +30,4 @@ def notify(event):
"""
for subscriber in subscribers:
subscriber(event)
+ return event
diff --git a/src/zope/event/classhandler.py b/src/zope/event/classhandler.py
index 0a1df59..a0ab1f6 100644
--- a/src/zope/event/classhandler.py
+++ b/src/zope/event/classhandler.py
@@ -34,7 +34,7 @@ Subscribers are called in class method-resolution order, so only
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
diff --git a/src/zope/event/tests.py b/src/zope/event/tests.py
index 740a1ac..5a541e4 100644
--- a/src/zope/event/tests.py
+++ b/src/zope/event/tests.py
@@ -29,7 +29,7 @@ class Test_notify(unittest.TestCase):
def _callFUT(self, event):
from zope.event import notify
- notify(event)
+ return notify(event)
def test_empty(self):
event = object()
@@ -43,6 +43,10 @@ class Test_notify(unittest.TestCase):
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