当前位置: 首页>>代码示例>>Python>>正文


Python Observable.unregister_all方法代码示例

本文整理汇总了Python中observable.Observable.unregister_all方法的典型用法代码示例。如果您正苦于以下问题:Python Observable.unregister_all方法的具体用法?Python Observable.unregister_all怎么用?Python Observable.unregister_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在observable.Observable的用法示例。


在下文中一共展示了Observable.unregister_all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: observerable_test

# 需要导入模块: from observable import Observable [as 别名]
# 或者: from observable.Observable import unregister_all [as 别名]
class observerable_test(unittest.TestCase):
 
    def setUp(self):
        self.observable = Observable()
 
        self.observer1 = AnObserver()
        self.observer2 = AnObserver()
        self.observer3 = AnObserver()
 
    def test_remove_all(self):
        self.observable.register(self.observer1)
        self.observable.register(self.observer2)
        self.observable.register(self.observer3)
 
        self.observable.unregister_all()
 
        # Should be zero registered
        self.assertEqual(len(self.observable.observers), 0)
 
    def test_register(self):
        self.observable.register(self.observer1)
        self.observable.register(self.observer2)
        self.observable.register(self.observer3)
 
        # Should be three registered
        self.assertEqual(len(self.observable.observers), 3)
        self.observable.unregister_all()
 
    def test_unregister(self):
        self.observable.register(self.observer1)
        self.observable.register(self.observer2)
        self.observable.register(self.observer3)
 
        self.observable.unregister(self.observer2)
        self.observable.unregister(self.observer3)
 
        # Should be one registered
        self.assertEqual(len(self.observable.observers), 1)
        self.observable.unregister_all()
 
    def test_update_observers(self):
        self.observable.register(self.observer1)
 
        self.observable.update_observers('abc', msg='123')
        self.assertEqual(self.observer1.args[0], 'abc')
        self.assertEqual(self.observer1.kwargs['msg'], '123')
        self.observable.unregister_all()
开发者ID:VibhiJha,项目名称:CMPE202_TeamProject,代码行数:49,代码来源:observable_test.py

示例2: observerable_test

# 需要导入模块: from observable import Observable [as 别名]
# 或者: from observable.Observable import unregister_all [as 别名]
class observerable_test(unittest.TestCase):
 
    def setUp(self):
        self.observable = Observable()
 
        self.observer1 = AnObserver()
        self.observer2 = AnObserver()
        self.observer3 = AnObserver()
 
    def test_remove_all(self):
        self.observable.register(self.observer1)
        self.observable.register(self.observer2)
        self.observable.register(self.observer3)
 
        self.observable.unregister_all()
 
        # Should be zero registered
        self.assertEqual(len(self.observable.observers), 0)
 
    def test_register(self):
        self.observable.register(self.observer1)
        self.observable.register(self.observer2)
        self.observable.register(self.observer3)
 
        # Should be three registered
        self.assertEqual(len(self.observable.observers), 3)
        self.observable.unregister_all()
 
    def test_unregister(self):
        self.observable.register(self.observer1)
        self.observable.register(self.observer2)
        self.observable.register(self.observer3)
 
        self.observable.unregister(self.observer2)
        self.observable.unregister(self.observer3)
 
        # Should be one registered
        self.assertEqual(len(self.observable.observers), 1)
        self.observable.unregister_all()
 
    '''   
开发者ID:akshatha0005,项目名称:CMPE202_TeamProject,代码行数:43,代码来源:observable_test.py


注:本文中的observable.Observable.unregister_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。