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


Python NotifyTestObject.assert_results方法代码示例

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


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

示例1: test_internals_1

# 需要导入模块: from test.__common import NotifyTestObject [as 别名]
# 或者: from test.__common.NotifyTestObject import assert_results [as 别名]
    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,代码行数:30,代码来源:base.py

示例2: test_handler_garbage_collection_3

# 需要导入模块: from test.__common import NotifyTestObject [as 别名]
# 或者: from test.__common.NotifyTestObject import assert_results [as 别名]
    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,代码行数:30,代码来源:signal.py

示例3: test_garbage_collection_binary

# 需要导入模块: from test.__common import NotifyTestObject [as 别名]
# 或者: from test.__common.NotifyTestObject import assert_results [as 别名]
    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,代码行数:31,代码来源:condition.py

示例4: test_garbage_collection_if_else

# 需要导入模块: from test.__common import NotifyTestObject [as 别名]
# 或者: from test.__common.NotifyTestObject import assert_results [as 别名]
    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,代码行数:32,代码来源:condition.py

示例5: test_garbage_collection_3

# 需要导入模块: from test.__common import NotifyTestObject [as 别名]
# 或者: from test.__common.NotifyTestObject import assert_results [as 别名]
    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,代码行数:34,代码来源:condition.py

示例6: test_argument_passing

# 需要导入模块: from test.__common import NotifyTestObject [as 别名]
# 或者: from test.__common.NotifyTestObject import assert_results [as 别名]
    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,代码行数:10,代码来源:signal.py

示例7: test_predicate_condition_2

# 需要导入模块: from test.__common import NotifyTestObject [as 别名]
# 或者: from test.__common.NotifyTestObject import assert_results [as 别名]
    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,代码行数:11,代码来源:condition.py

示例8: test_with_changes_frozen_1

# 需要导入模块: from test.__common import NotifyTestObject [as 别名]
# 或者: from test.__common.NotifyTestObject import assert_results [as 别名]
    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,代码行数:11,代码来源:base.py

示例9: test_connect

# 需要导入模块: from test.__common import NotifyTestObject [as 别名]
# 或者: from test.__common.NotifyTestObject import assert_results [as 别名]
    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,代码行数:12,代码来源:signal.py

示例10: test_changes_frozen_2

# 需要导入模块: from test.__common import NotifyTestObject [as 别名]
# 或者: from test.__common.NotifyTestObject import assert_results [as 别名]
    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,代码行数:12,代码来源:base.py

示例11: test_predicate_condition_3

# 需要导入模块: from test.__common import NotifyTestObject [as 别名]
# 或者: from test.__common.NotifyTestObject import assert_results [as 别名]
    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,代码行数:13,代码来源:condition.py

示例12: test_disconnect

# 需要导入模块: from test.__common import NotifyTestObject [as 别名]
# 或者: from test.__common.NotifyTestObject import assert_results [as 别名]
    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,代码行数:13,代码来源:signal.py

示例13: test_block

# 需要导入模块: from test.__common import NotifyTestObject [as 别名]
# 或者: from test.__common.NotifyTestObject import assert_results [as 别名]
    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,代码行数:13,代码来源:signal.py

示例14: test_connecting_1

# 需要导入模块: from test.__common import NotifyTestObject [as 别名]
# 或者: from test.__common.NotifyTestObject import assert_results [as 别名]
    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,代码行数:14,代码来源:signal.py

示例15: test_storing_1

# 需要导入模块: from test.__common import NotifyTestObject [as 别名]
# 或者: from test.__common.NotifyTestObject import assert_results [as 别名]
    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,代码行数:14,代码来源:base.py


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