mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-06 13:06:53 +00:00
Start adding tests for Notifier class
This commit is contained in:
parent
d1d1d60032
commit
222be9ac49
2 changed files with 32 additions and 1 deletions
31
tests/test_notifier.py
Normal file
31
tests/test_notifier.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import pytest
|
||||
|
||||
from flake8 import notifier
|
||||
|
||||
class _Listener(object):
|
||||
def __init__(self, error_code):
|
||||
self.error_code = error_code
|
||||
self.was_notified = False
|
||||
|
||||
def notify(self, error_code, *args, **kwargs):
|
||||
assert self.error_code == error_code
|
||||
self.was_notified = True
|
||||
|
||||
|
||||
class TestNotifier(object):
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup(self):
|
||||
self.notifier = notifier.Notifier()
|
||||
self.listener_map = {}
|
||||
|
||||
for i in range(10):
|
||||
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)
|
||||
|
||||
def test_notify_a_single_error_code(self):
|
||||
"""Show that we notify a specific error code."""
|
||||
self.notifier.notify('E111', 'extra', 'args')
|
||||
assert self.listener_map['E111'].was_notified is True
|
||||
Loading…
Add table
Add a link
Reference in a new issue