本文整理汇总了Python中tests.samples.SampleBase.bound_method方法的典型用法代码示例。如果您正苦于以下问题:Python SampleBase.bound_method方法的具体用法?Python SampleBase.bound_method怎么用?Python SampleBase.bound_method使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.samples.SampleBase
的用法示例。
在下文中一共展示了SampleBase.bound_method方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_expects_bound_method_returns
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import bound_method [as 别名]
def test_expects_bound_method_returns(self):
obj = SampleBase()
expect(obj.bound_method).args(1, 2).returns(12)
assert_equals(12, obj.bound_method(1, 2))
expect(obj.bound_method).args(1, 4).returns(1100)
assert_equals(1100, obj.bound_method(1, 4))
示例2: test_expect_bound_method_with_allof_comparator
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import bound_method [as 别名]
def test_expect_bound_method_with_allof_comparator(self):
obj = SampleBase()
expect(obj.bound_method).args( all_of(length(5),'hello') )
obj.bound_method( 'hello' )
expect(obj.bound_method).args( all_of(length(3),'hello') ).at_least(0)
assert_raises(UnexpectedCall, obj.bound_method, 'hello' )
示例3: test_expects_bound_method_at_least_as_last_expectation
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import bound_method [as 别名]
def test_expects_bound_method_at_least_as_last_expectation(self):
obj = SampleBase()
expect(obj.bound_method).args(1, 2).returns(12).at_least(3)
assert_equals(12, obj.bound_method(1, 2))
assert_equals(12, obj.bound_method(1, 2))
assert_equals(12, obj.bound_method(1, 2))
assert_equals(12, obj.bound_method(1, 2))
示例4: test_expects_bound_method_at_most
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import bound_method [as 别名]
def test_expects_bound_method_at_most(self):
obj = SampleBase()
expect(obj.bound_method).args(1, 2).returns(12).at_most(3)
assert_equals(12, obj.bound_method(1, 2))
assert_equals(12, obj.bound_method(1, 2))
obj.bound_method(1, 2)
assert_raises(UnexpectedCall, obj.bound_method, 1, 2)
示例5: test_expects_bound_method_can_be_used_for_iterative_testing
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import bound_method [as 别名]
def test_expects_bound_method_can_be_used_for_iterative_testing(self):
obj = SampleBase()
expect(obj.bound_method).args(1, 2).returns(12)
assert_equals(12, obj.bound_method(1, 2))
assert_raises(UnexpectedCall, obj.bound_method)
expect(obj.bound_method).args(1, 4).returns(1100)
assert_equals(1100, obj.bound_method(1, 4))
示例6: test_expects_any_order_without_count_modifiers
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import bound_method [as 别名]
def test_expects_any_order_without_count_modifiers(self):
obj = SampleBase()
expect(obj.bound_method).args(3).returns(4)
expect(obj.bound_method).args(1).returns(2).any_order()
expect(obj.bound_method).args(3).returns(4)
assert_equals(4, obj.bound_method(3) )
assert_equals(4, obj.bound_method(3) )
assert_equals(2, obj.bound_method(1) )
示例7: test_expect_unbound_method_acts_as_any_instance
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import bound_method [as 别名]
def test_expect_unbound_method_acts_as_any_instance(self):
expect( SampleBase.bound_method ).args('hello').returns('world')
expect( SampleBase.bound_method ).args('hello').returns('mars')
obj1 = SampleBase()
obj2 = SampleBase()
assert_equals( 'world', obj2.bound_method('hello') )
assert_equals( 'mars', obj1.bound_method('hello') )
assert_raises(UnexpectedCall, obj2.bound_method)
示例8: test_expects_bound_method_at_least_with_other_expectation_and_anyorder
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import bound_method [as 别名]
def test_expects_bound_method_at_least_with_other_expectation_and_anyorder(self):
obj = SampleBase()
expect(obj.bound_method).args(1, 2).returns(12).at_least(2).any_order()
assert_equals(12, obj.bound_method(1, 2))
assert_equals(12, obj.bound_method(1, 2))
expect(obj.bound_method).args(1, 3).returns(100)
assert_equals(100, obj.bound_method(1, 3))
assert_equals(12, obj.bound_method(1, 2))
示例9: tests_expects_bound_method_any_order_with_mins
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import bound_method [as 别名]
def tests_expects_bound_method_any_order_with_mins(self):
obj = SampleBase()
expect(obj.bound_method).args(1).returns(2).any_order().at_least_once()
expect(obj.bound_method).args(3).returns(4).any_order().at_least_once()
assert_equals(4, obj.bound_method(3) )
assert_equals(2, obj.bound_method(1) )
assert_equals(4, obj.bound_method(3) )
assert_equals(2, obj.bound_method(1) )
assert_equals(2, obj.bound_method(1) )
assert_equals(4, obj.bound_method(3) )
assert_equals(2, obj.bound_method(1) )
示例10: tests_expects_bound_method_any_order_with_fixed_maxes
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import bound_method [as 别名]
def tests_expects_bound_method_any_order_with_fixed_maxes(self):
obj = SampleBase()
expect(obj.bound_method).args(1).returns(2).any_order()
expect(obj.bound_method).args(3).returns(4).any_order()
assert_equals(4, obj.bound_method(3) )
assert_equals(2, obj.bound_method(1) )
assert_raises(UnexpectedCall, obj.bound_method, 1)
示例11: test_expect_bound_method_with_anyof_comparator
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import bound_method [as 别名]
def test_expect_bound_method_with_anyof_comparator(self):
obj = SampleBase()
expect(obj.bound_method).times(4).args(
any_of(int, 3.14, 'hello', is_a(list)))
obj.bound_method(42)
obj.bound_method(3.14)
obj.bound_method('hello')
obj.bound_method([1, 2, 3])
assert_raises(UnexpectedCall, obj.bound_method, '42')
示例12: test_expect_bound_method_with_equals_comparator
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import bound_method [as 别名]
def test_expect_bound_method_with_equals_comparator(self):
obj = SampleBase()
expect(obj.bound_method).args( equals(42) )
obj.bound_method( 42 )
assert_raises(UnexpectedCall, obj.bound_method, 32 )
示例13: test_function_comparator
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import bound_method [as 别名]
def test_function_comparator(self):
obj = SampleBase()
expect(obj.bound_method).args(func(lambda arg: arg > 10)).returns(100)
assert_equals(obj.bound_method(100), 100)
示例14: test_expect_bound_method_with_notof_comparator_using_types
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import bound_method [as 别名]
def test_expect_bound_method_with_notof_comparator_using_types(self):
obj = SampleBase()
expect(obj.bound_method).args( not_of(float,int) )
obj.bound_method( 'hello' )
示例15: test_expect_bound_method_with_is_a_comparator
# 需要导入模块: from tests.samples import SampleBase [as 别名]
# 或者: from tests.samples.SampleBase import bound_method [as 别名]
def test_expect_bound_method_with_is_a_comparator(self):
obj = SampleBase()
expect(obj.bound_method).args( is_a(int) )
obj.bound_method( 42 )
assert_raises(UnexpectedCall, obj.bound_method, '42' )