示例#1
0
async def test_notifier_remove_observer(notifier: Notifier):
    def callback1():
        ...

    def callback2():
        ...

    notifier.add_observer('topic', callback1)
    notifier.add_observer('topic', callback2)

    notifier.remove_observer('topic', callback1)
    assert notifier.observers['topic'] == {callback2: True}
示例#2
0
async def test_notifier_remove_nonexistent_observer(notifier: Notifier):
    # test that `remove_observer` don't crash in case of calling to remove non existed topic/callback
    notifier.remove_observer('nonexistent', lambda: None)
    assert not notifier.observers['nonexistent']