• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python __common.NotifyTestObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中test.__common.NotifyTestObject的典型用法代码示例。如果您正苦于以下问题:Python NotifyTestObject类的具体用法?Python NotifyTestObject怎么用?Python NotifyTestObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: test_internals_1

    def test_internals_1 (self):
        test = NotifyTestObject ()

        condition     = Condition (False)
        not_condition = ~condition

        self.assert_(not not_condition._has_signal ())

        not_condition.changed.connect (test.simple_handler)
        self.assert_(not_condition._has_signal ())

        def set_state_true ():
            condition.state = True

        condition.with_changes_frozen (set_state_true)

        condition.state = False

        not_condition.changed.disconnect (test.simple_handler)
        self.collect_garbage ()
        self.assert_(not not_condition._has_signal ())

        not_condition.changed.connect (test.simple_handler)
        self.assert_(not_condition._has_signal ())

        condition.state = True

        test.assert_results (False, True, False)
开发者ID:Distrotech,项目名称:python-notify,代码行数:28,代码来源:base.py


示例2: test_handler_garbage_collection_3

    def test_handler_garbage_collection_3 (self):
        test   = NotifyTestObject ()
        signal = Signal (AbstractSignal.ANY_ACCEPTS)

        handler = HandlerGarbageCollectionTestCase.HandlerObject (test)

        def accepting_handler (*arguments):
            test.simple_handler_100 (*arguments)
            return arguments[0]

        signal.connect (accepting_handler)
        signal.connect (handler.simple_handler)

        self.assertEqual (len (signal._handlers), 2)

        signal.emit (1)

        del handler
        self.collect_garbage ()

        self.assertEqual (len (signal._handlers), 2)

        signal.emit (2)

        # This time emission is stopped by accumulator, but still the gc-collected handler
        # must be removed.
        self.assertEqual (len (signal._handlers), 1)
        test.assert_results (101, 102)
开发者ID:berinhard,项目名称:py-notify,代码行数:28,代码来源:signal.py


示例3: test_garbage_collection_binary

    def test_garbage_collection_binary (self):
        for _operator in (operator.__and__, operator.__or__, operator.__xor__):
            test = NotifyTestObject ()

            condition1       = Condition (True)
            condition2       = Condition (False)
            binary_condition = _operator (condition1, condition2)

            binary_condition.store (test.simple_handler)
            binary_condition = weakref.ref (binary_condition)

            del condition1
            self.collect_garbage ()

            self.assertNotEqual (binary_condition (), None)

            condition2.state = True

            del condition2
            self.collect_garbage ()

            self.assertEqual (binary_condition (), None)

            expected_results = []
            for state1, state2 in ((True, False), (True, True)):
                if not expected_results or expected_results[-1] != _operator (state1, state2):
                    expected_results.append (_operator (state1, state2))

            test.assert_results (*expected_results)
开发者ID:Distrotech,项目名称:python-notify,代码行数:29,代码来源:condition.py


示例4: test_garbage_collection_if_else

    def test_garbage_collection_if_else (self):
        test              = NotifyTestObject ()

        condition1        = Condition (False)
        condition2        = Condition (False)
        condition3        = Condition (True)
        if_else_condition = condition1.if_else (condition2, condition3)

        if_else_condition.store (test.simple_handler)
        if_else_condition = weakref.ref (if_else_condition)

        del condition2
        self.collect_garbage ()

        self.assertNotEqual (if_else_condition (), None)

        condition3.state = False

        del condition1
        self.collect_garbage ()

        self.assertNotEqual (if_else_condition (), None)

        condition3.state = True

        del condition3
        self.collect_garbage ()

        self.assertEqual    (if_else_condition (), None)
        test.assert_results (True, False, True)
开发者ID:Distrotech,项目名称:python-notify,代码行数:30,代码来源:condition.py


示例5: test_garbage_collection_3

    def test_garbage_collection_3 (self):
        test = NotifyTestObject ()

        variable = Variable ()

        condition1 = variable.is_true ()
        condition2 = ~condition1
        condition2.store (test.simple_handler)

        condition1 = weakref.ref (condition1)
        condition2 = weakref.ref (condition2)

        self.collect_garbage ()
        self.assertNotEqual (condition1 (), None)
        self.assertNotEqual (condition2 (), None)

        self.collect_garbage ()
        variable.value = 10

        condition2 ().changed.disconnect (test.simple_handler)

        self.collect_garbage ()

        self.assertEqual (condition1 (), None)
        self.assertEqual (condition2 (), None)

        variable = weakref.ref (variable)
        self.collect_garbage ()

        self.assertEqual (variable (), None)

        test.assert_results (True, False)
开发者ID:Distrotech,项目名称:python-notify,代码行数:32,代码来源:condition.py


示例6: test_argument_passing

    def test_argument_passing (self):
        test   = NotifyTestObject ()
        signal = Signal ()

        signal.connect (test.simple_handler)
        signal.emit (45, 'abc')

        test.assert_results ((45, 'abc'))
开发者ID:berinhard,项目名称:py-notify,代码行数:8,代码来源:signal.py


示例7: test_predicate_condition_2

    def test_predicate_condition_2 (self):
        test = NotifyTestObject ()

        predicate = PredicateCondition (bool, None)
        predicate.store (test.simple_handler)

        predicate.update (False)

        test.assert_results (False)
开发者ID:Distrotech,项目名称:python-notify,代码行数:9,代码来源:condition.py


示例8: test_with_changes_frozen_1

    def test_with_changes_frozen_1 (self):
        test     = NotifyTestObject ()
        variable = Variable ()

        variable.changed.connect (test.simple_handler)
        variable.with_changes_frozen (lambda: None)

        # Must not emit `changed' signal: no changes at all.
        test.assert_results ()
开发者ID:Distrotech,项目名称:python-notify,代码行数:9,代码来源:base.py


示例9: test_connect

    def test_connect (self):
        test   = NotifyTestObject ()
        signal = Signal ()

        signal.connect (test.simple_handler)
        signal.emit ()

        self.assert_        (signal.has_handlers ())
        self.assert_        (signal)
        test.assert_results (())
开发者ID:berinhard,项目名称:py-notify,代码行数:10,代码来源:signal.py


示例10: test_changes_frozen_2

    def test_changes_frozen_2 (self):
        test     = NotifyTestObject ()
        variable = Variable ()

        variable.changed.connect (test.simple_handler)

        with variable.changes_frozen ():
            variable.value = 1

        test.assert_results (1)
开发者ID:Distrotech,项目名称:python-notify,代码行数:10,代码来源:base.py


示例11: test_predicate_condition_3

    def test_predicate_condition_3 (self):
        test = NotifyTestObject ()

        predicate = PredicateCondition (lambda x: x > 10, 0)
        predicate.store (test.simple_handler)

        predicate.update (10)
        predicate.update (20)
        predicate.update (-5)

        test.assert_results (False, True, False)
开发者ID:Distrotech,项目名称:python-notify,代码行数:11,代码来源:condition.py


示例12: test_disconnect

    def test_disconnect (self):
        test   = NotifyTestObject ()
        signal = Signal ()

        signal.connect (test.simple_handler)
        signal.emit ()

        signal.disconnect (test.simple_handler)
        signal.emit ()

        test.assert_results (())
开发者ID:berinhard,项目名称:py-notify,代码行数:11,代码来源:signal.py


示例13: test_block

    def test_block (self):
        test   = NotifyTestObject ()
        signal = Signal ()

        signal.connect (test.simple_handler)
        signal.emit (1)

        signal.block (test.simple_handler)
        signal.emit (2)

        test.assert_results (1)
开发者ID:berinhard,项目名称:py-notify,代码行数:11,代码来源:signal.py


示例14: test_connecting_1

    def test_connecting_1 (self):
        test   = NotifyTestObject ()
        signal = Signal ()

        signal.emit (1)

        with signal.connecting (test.simple_handler):
            signal.emit (2)

        signal.emit (3)

        test.assert_results (2)
开发者ID:Distrotech,项目名称:python-notify,代码行数:12,代码来源:signal.py


示例15: test_storing_1

    def test_storing_1 (self):
        test = NotifyTestObject ()

        variable       = Variable ()
        variable.value = 100

        with variable.storing (test.simple_handler):
            variable.value = 200

        variable.value = 300

        test.assert_results (100, 200)
开发者ID:Distrotech,项目名称:python-notify,代码行数:12,代码来源:base.py


示例16: test_connect_with_arguments

    def test_connect_with_arguments (self):
        test   = NotifyTestObject ()
        signal = Signal ()

        signal.connect_safe (test.simple_handler, 'one argument')
        signal.connect_safe (test.simple_handler, 'first', 'second', 3)

        signal.emit ()
        signal.emit ('a', 'b')

        test.assert_results ('one argument', ('first', 'second', 3),
                             ('one argument', 'a', 'b'), ('first', 'second', 3, 'a', 'b'))
开发者ID:berinhard,项目名称:py-notify,代码行数:12,代码来源:signal.py


示例17: test_emission_stop_1

    def test_emission_stop_1 (self):
        def stop_emission ():
            signal.stop_emission ()

        test   = NotifyTestObject ()
        signal = Signal ()

        signal.connect (stop_emission)
        signal.connect (test.simple_handler)
        signal.emit    ()

        test.assert_results ()
开发者ID:berinhard,项目名称:py-notify,代码行数:12,代码来源:signal.py


示例18: test_mixed_argument_passing

    def test_mixed_argument_passing (self):
        test   = NotifyTestObject ()
        signal = Signal ()

        signal.connect (test.simple_keywords_handler)
        signal.emit (ham = 'spam')
        signal.emit (42)
        signal.emit (1, 2, 3, foo = 'bar')

        test.assert_results ({ 'ham': 'spam' },
                             (42, { }),
                             (1, 2, 3, { 'foo': 'bar' }))
开发者ID:berinhard,项目名称:py-notify,代码行数:12,代码来源:signal.py


示例19: test_changes_frozen_4

    def test_changes_frozen_4 (self):
        test     = NotifyTestObject ()
        variable = Variable ()

        variable.changed.connect (test.simple_handler)

        with variable.changes_frozen ():
            variable.value = 1
            variable.value = None

        # Must not emit: value returned to original.
        test.assert_results ()
开发者ID:Distrotech,项目名称:python-notify,代码行数:12,代码来源:base.py


示例20: test_predicate_2

    def test_predicate_2 (self):
        test = NotifyTestObject ()

        variable = Variable (0)
        variable.predicate (lambda value: 0 <= value < 10).store (test.simple_handler)

        variable.value = 5
        variable.value = 15
        variable.value = -1
        variable.value = 9
        variable.value = 3

        test.assert_results (True, False, True)
开发者ID:Distrotech,项目名称:python-notify,代码行数:13,代码来源:variable.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python _common.item函数代码示例发布时间:2022-05-27
下一篇:
Python TestUtils.TestUtils类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap