summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2015-12-29 23:28:20 -0600
committerIan Cordasco <graffatcolmingov@gmail.com>2015-12-29 23:28:20 -0600
commit37b92cd4b47723115f9e27760307b10508808bc6 (patch)
tree233ba18cc526cc0b19b7642a41985052a118edc4 /tests
parent222be9ac4918d2ea85e9ac3d20832106c10d30a1 (diff)
downloadflake8-37b92cd4b47723115f9e27760307b10508808bc6.tar.gz
Fix logic for Notifier.listeners_for
Add tests for proper logic around notifier
Diffstat (limited to 'tests')
-rw-r--r--tests/test_notifier.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/test_notifier.py b/tests/test_notifier.py
index 44f2dc9..b0365f3 100644
--- a/tests/test_notifier.py
+++ b/tests/test_notifier.py
@@ -8,7 +8,7 @@ class _Listener(object):
self.was_notified = False
def notify(self, error_code, *args, **kwargs):
- assert self.error_code == error_code
+ assert error_code.startswith(self.error_code)
self.was_notified = True
@@ -18,14 +18,18 @@ class TestNotifier(object):
self.notifier = notifier.Notifier()
self.listener_map = {}
+ def add_listener(error_code):
+ listener = _Listener(error_code)
+ self.listener_map[error_code] = listener
+ self.notifier.register_listener(error_code, listener)
+
for i in range(10):
+ add_listener('E{0}'.format(i))
for j in range(30):
- error_code = 'E{0}{1:02d}'.format(i, j)
- listener = _Listener(error_code)
- self.listener_map[error_code] = listener
- self.notifier.register_listener(error_code, listener)
+ add_listener('E{0}{1:02d}'.format(i, j))
- def test_notify_a_single_error_code(self):
+ def test_notify(self):
"""Show that we notify a specific error code."""
self.notifier.notify('E111', 'extra', 'args')
assert self.listener_map['E111'].was_notified is True
+ assert self.listener_map['E1'].was_notified is True