Пример #1
0
 def test_on_change_bad_functor(self) -> None:
     m = cbm.EventCallbackManager()
     m.subscribed_events = []
     bad = _BadEventCallback()
     m.on_event('foo', bad)
     assert len(m._event_callbacks) == 1
Пример #2
0
 def test_on_change_bad_function(self) -> None:
     m = cbm.EventCallbackManager()
     m.subscribed_events = []
     with pytest.raises(ValueError):
         m.on_event('foo', _bad_event)
     assert len(m._event_callbacks) == 0
Пример #3
0
 def test_on_change_good_function(self) -> None:
     m = cbm.EventCallbackManager()
     m.subscribed_events = []
     m.on_event('foo', _good_event)
     assert len(m._event_callbacks) == 1
     assert m._event_callbacks['foo'] == [_good_event]
Пример #4
0
 def test_on_change_unicode_event_name(self) -> None:
     m = cbm.EventCallbackManager()
     m.subscribed_events = []
     m.on_event("foo", _good_event)
     assert len(m._event_callbacks) == 1
     assert m._event_callbacks['foo'] == [_good_event]
Пример #5
0
 def test_on_change_bad_partial_function(self) -> None:
     m = cbm.EventCallbackManager()
     p = partial(_partially_bad_event, 'foo')
     m.subscribed_events = []
     m.on_event('foo', p)
     assert len(m._event_callbacks) == 1
Пример #6
0
 def test_creation(self) -> None:
     m = cbm.EventCallbackManager()
     assert len(m._event_callbacks) == 0
 def test_on_change_bad_lambda(self):
     m = cbm.EventCallbackManager()
     m.subscribed_events = []
     with pytest.raises(ValueError):
         m.on_event('foo', lambda x, y: x)
     assert len(m._event_callbacks) == 0
def test_event_creation():
    m = cbm.EventCallbackManager()
    assert len(m._event_callbacks) == 0
Пример #9
0
 def test_on_change_bad_method(self):
     m = cbm.EventCallbackManager()
     m.subscribed_events = []
     bad = _BadEventCallback()
     m.on_event('foo', bad.method)
     assert len(m._event_callbacks) == 1