Skip to content

Commit

Permalink
Class based notifications receive a static send method
Browse files Browse the repository at this point in the history
  • Loading branch information
flashingpumpkin committed Feb 26, 2013
1 parent d786189 commit 07fb177
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion yell/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.3.1"
__version__ = "0.3.2"

import registry

Expand All @@ -12,6 +12,9 @@ def __new__(cls, name, bases, attrs):
if Notification.name is not None:
registry.notifications[Notification.name] = registry.notifications.get(Notification.name, []) + [Notification]

sendfn = lambda *args, **kwargs: notify(Notification.name, backends = [Notification], *args, **kwargs)
setattr(Notification, 'send', staticmethod(sendfn))

return Notification


Expand Down
5 changes: 4 additions & 1 deletion yell/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,7 @@ def test_notifying_once_with_class(self):
self.assertEqual(1, len(results))
self._assert_results(results)


def test_notifying_with_send_static_method(self):
results = ClassNotification0.send('Arg1', 'Arg2', kwarg1='Kwarg1', kwarg2='Kwarg2')
self.assertEqual(1, len(results))
self._assert_results(results)

0 comments on commit 07fb177

Please sign in to comment.