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


Python InstanceDouble.method_with_varargs方法代码示例

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


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

示例1: test_with_args_validator

# 需要导入模块: from doubles.instance_double import InstanceDouble [as 别名]
# 或者: from doubles.instance_double.InstanceDouble import method_with_varargs [as 别名]
    def test_with_args_validator(self):
        subject = InstanceDouble('doubles.testing.User')

        expect(subject).method_with_varargs.with_args_validator(
            lambda *args: args[0] == 'Bob Barker'
        )
        subject.method_with_varargs('Bob Barker', 'Drew Carey')
开发者ID:uber,项目名称:doubles,代码行数:9,代码来源:expect_test.py

示例2: test_matches_most_specific_allowance

# 需要导入模块: from doubles.instance_double import InstanceDouble [as 别名]
# 或者: from doubles.instance_double.InstanceDouble import method_with_varargs [as 别名]
    def test_matches_most_specific_allowance(self):
        subject = InstanceDouble('doubles.testing.User')

        allow(subject).method_with_varargs.and_return('bar')
        allow(subject).method_with_varargs.with_args('baz').and_return('blah')

        assert subject.method_with_varargs('baz') == 'blah'
开发者ID:sladebot,项目名称:doubles,代码行数:9,代码来源:allow_test.py

示例3: test_returns_result_of_a_callable_with_positional_vargs

# 需要导入模块: from doubles.instance_double import InstanceDouble [as 别名]
# 或者: from doubles.instance_double.InstanceDouble import method_with_varargs [as 别名]
    def test_returns_result_of_a_callable_with_positional_vargs(self, stubber):
        subject = InstanceDouble('doubles.testing.User')

        stubber(subject).method_with_varargs.and_return_result_of(lambda *x: x)

        result = subject.method_with_varargs('bob', 'barker')
        assert result == ('bob', 'barker')
开发者ID:uber,项目名称:doubles,代码行数:9,代码来源:return_values_test.py

示例4: test_raises_if_method_is_called_with_wrong_arguments

# 需要导入模块: from doubles.instance_double import InstanceDouble [as 别名]
# 或者: from doubles.instance_double.InstanceDouble import method_with_varargs [as 别名]
    def test_raises_if_method_is_called_with_wrong_arguments(self):
        subject = InstanceDouble('doubles.testing.User')

        allow(subject).method_with_varargs.with_args('bar')

        with raises(UnallowedMethodCallError) as e:
            subject.method_with_varargs('baz')

        assert re.match(
            r"Received unexpected call to 'method_with_varargs' on "
            r"<InstanceDouble of <class '?doubles.testing.User'?"
            r"(?: at 0x[0-9a-f]{9})?> object at .+>\."
            r"  The supplied arguments \('baz'\)"
            r" do not match any available allowances.",
            str(e.value)
        )
开发者ID:sladebot,项目名称:doubles,代码行数:18,代码来源:allow_test.py


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