本文整理汇总了Python中tests.samples.SampleBase.add_to_list方法的典型用法代码示例。如果您正苦于以下问题:Python SampleBase.add_to_list方法的具体用法?Python SampleBase.add_to_list怎么用?Python SampleBase.add_to_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.samples.SampleBase
的用法示例。
在下文中一共展示了SampleBase.add_to_list方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_to_list_with_module_mock_object
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import add_to_list [as 别名]
def test_add_to_list_with_module_mock_object(self):
mock( samples, 'deque' )
deq = mock()
expect( samples.deque.__call__ ).returns( deq )
expect( deq.append ).args('value')
obj = SampleBase()
obj.add_to_list('value')
示例2: test_var_comparator
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import add_to_list [as 别名]
def test_var_comparator(self):
obj = SampleBase()
expect(obj.add_to_list).args( var('value1') )
expect(obj.add_to_list).args( var('value2') )
expect(obj.add_to_list).args( var('value3') ).at_least_once()
obj.add_to_list('v1')
obj.add_to_list('v2')
obj.add_to_list('v3')
obj.add_to_list('v3')
self.assertRaises( UnexpectedCall, obj.add_to_list, 'v3a')
assert_equals( 'v1', var('value1').value )
assert_equals( 'v2', var('value2').value )
assert_equals( 'v3', var('value3').value )
示例3: test_spy
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import add_to_list [as 别名]
def test_spy(self):
spy(SampleBase)
obj = SampleBase()
assert_true(isinstance(obj,SampleBase))
spy(obj.add_to_list)
obj.add_to_list('v1')
assert_equals(['v1'], list(obj._deque))
spy(obj.add_to_list).args( var('value2') )
obj.add_to_list('v2')
assert_equals(['v1','v2'], list(obj._deque))
assert_equals( 'v2', var('value2').value )
# Have to use times(0) because we don't actually expect this to be called
with assert_raises(UnsupportedModifier):
spy(obj.add_to_list).times(0).side_effect(lambda x: x)
with assert_raises(UnsupportedModifier):
spy(obj.add_to_list).times(0).returns(3)
with assert_raises(UnsupportedModifier):
spy(obj.add_to_list).times(0).raises(Exception('oops'))
示例4: test_add_to_list_with_mock_object
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import add_to_list [as 别名]
def test_add_to_list_with_mock_object(self):
obj = SampleBase()
obj._deque = mock()
expect( obj._deque.append ).args('value')
obj.add_to_list('value')