本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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'))
示例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)
示例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 ()
示例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 (())
示例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)
示例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)
示例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 (())
示例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)
示例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)
示例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)