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


Python mock._Call方法代码示例

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


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

示例1: HasExactlyCalls

# 需要导入模块: from mock import mock [as 别名]
# 或者: from mock.mock import _Call [as 别名]
def HasExactlyCalls(self, *calls):
    """Assert that the mocked function was called with exactly the given calls.

    Args:
      *calls: iterable of mock.call objects. Developers may also pass a single
          iterable of mock.call objects, for compatibility with mock's
          assert_has_calls() method, although this form is not preferred.

    Returns:
      If the mocked function was called exactly with the expected calls, returns
      an _Ordered predicate on which .InOrder() can be subsequently called.

    Raises:
      TruthAssertionError: the mocked function is missing any of the expected
          calls, or it contains any call not in the expected calls.
    """
    # If the caller passed an iterable of mock.call objects, expand them.
    # mock.call objects are themselves iterable, hence the third condition.
    if (len(calls) == 1 and _IsIterable(calls[0])
        # pylint: disable=protected-access
        and not isinstance(calls[0], mock._Call)):
        # pylint: enable=protected-access
      calls = calls[0]

    return AssertThat(self._actual.mock_calls).ContainsExactlyElementsIn(calls) 
开发者ID:google,项目名称:pytruth,代码行数:27,代码来源:truth.py

示例2: test_call_with_call

# 需要导入模块: from mock import mock [as 别名]
# 或者: from mock.mock import _Call [as 别名]
def test_call_with_call(self):
        kall = _Call()
        self.assertEqual(kall, _Call())
        self.assertEqual(kall, _Call(('',)))
        self.assertEqual(kall, _Call(((),)))
        self.assertEqual(kall, _Call(({},)))
        self.assertEqual(kall, _Call(('', ())))
        self.assertEqual(kall, _Call(('', {})))
        self.assertEqual(kall, _Call(('', (), {})))
        self.assertEqual(kall, _Call(('foo',)))
        self.assertEqual(kall, _Call(('bar', ())))
        self.assertEqual(kall, _Call(('baz', {})))
        self.assertEqual(kall, _Call(('spam', (), {})))

        kall = _Call(((1, 2, 3),))
        self.assertEqual(kall, _Call(((1, 2, 3),)))
        self.assertEqual(kall, _Call(('', (1, 2, 3))))
        self.assertEqual(kall, _Call(((1, 2, 3), {})))
        self.assertEqual(kall, _Call(('', (1, 2, 3), {})))

        kall = _Call(((1, 2, 4),))
        self.assertNotEqual(kall, _Call(('', (1, 2, 3))))
        self.assertNotEqual(kall, _Call(('', (1, 2, 3), {})))

        kall = _Call(('foo', (1, 2, 4),))
        self.assertNotEqual(kall, _Call(('', (1, 2, 4))))
        self.assertNotEqual(kall, _Call(('', (1, 2, 4), {})))
        self.assertNotEqual(kall, _Call(('bar', (1, 2, 4))))
        self.assertNotEqual(kall, _Call(('bar', (1, 2, 4), {})))

        kall = _Call(({'a': 3},))
        self.assertEqual(kall, _Call(('', (), {'a': 3})))
        self.assertEqual(kall, _Call(('', {'a': 3})))
        self.assertEqual(kall, _Call(((), {'a': 3})))
        self.assertEqual(kall, _Call(({'a': 3},))) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:37,代码来源:testhelpers.py

示例3: test_empty__Call

# 需要导入模块: from mock import mock [as 别名]
# 或者: from mock.mock import _Call [as 别名]
def test_empty__Call(self):
        args = _Call()

        self.assertEqual(args, ())
        self.assertEqual(args, ('foo',))
        self.assertEqual(args, ((),))
        self.assertEqual(args, ('foo', ()))
        self.assertEqual(args, ('foo',(), {}))
        self.assertEqual(args, ('foo', {}))
        self.assertEqual(args, ({},)) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:12,代码来源:testhelpers.py

示例4: test_named_empty_call

# 需要导入模块: from mock import mock [as 别名]
# 或者: from mock.mock import _Call [as 别名]
def test_named_empty_call(self):
        args = _Call(('foo', (), {}))

        self.assertEqual(args, ('foo',))
        self.assertEqual(args, ('foo', ()))
        self.assertEqual(args, ('foo',(), {}))
        self.assertEqual(args, ('foo', {}))

        self.assertNotEqual(args, ((),))
        self.assertNotEqual(args, ())
        self.assertNotEqual(args, ({},))
        self.assertNotEqual(args, ('bar',))
        self.assertNotEqual(args, ('bar', ()))
        self.assertNotEqual(args, ('bar', {})) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:16,代码来源:testhelpers.py

示例5: test_call_with_args

# 需要导入模块: from mock import mock [as 别名]
# 或者: from mock.mock import _Call [as 别名]
def test_call_with_args(self):
        args = _Call(((1, 2, 3), {}))

        self.assertEqual(args, ((1, 2, 3),))
        self.assertEqual(args, ('foo', (1, 2, 3)))
        self.assertEqual(args, ('foo', (1, 2, 3), {}))
        self.assertEqual(args, ((1, 2, 3), {})) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:9,代码来源:testhelpers.py

示例6: test_named_call_with_args

# 需要导入模块: from mock import mock [as 别名]
# 或者: from mock.mock import _Call [as 别名]
def test_named_call_with_args(self):
        args = _Call(('foo', (1, 2, 3), {}))

        self.assertEqual(args, ('foo', (1, 2, 3)))
        self.assertEqual(args, ('foo', (1, 2, 3), {}))

        self.assertNotEqual(args, ((1, 2, 3),))
        self.assertNotEqual(args, ((1, 2, 3), {})) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:10,代码来源:testhelpers.py

示例7: test_named_call_with_kwargs

# 需要导入模块: from mock import mock [as 别名]
# 或者: from mock.mock import _Call [as 别名]
def test_named_call_with_kwargs(self):
        args = _Call(('foo', (), dict(a=3, b=4)))

        self.assertEqual(args, ('foo', dict(a=3, b=4)))
        self.assertEqual(args, ('foo', (), dict(a=3, b=4)))

        self.assertNotEqual(args, (dict(a=3, b=4),))
        self.assertNotEqual(args, ((), dict(a=3, b=4))) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:10,代码来源:testhelpers.py

示例8: test_call_with_args_call_empty_name

# 需要导入模块: from mock import mock [as 别名]
# 或者: from mock.mock import _Call [as 别名]
def test_call_with_args_call_empty_name(self):
        args = _Call(((1, 2, 3), {}))
        self.assertEqual(args, call(1, 2, 3))
        self.assertEqual(call(1, 2, 3), args)
        self.assertIn(call(1, 2, 3), [args]) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:7,代码来源:testhelpers.py

示例9: test_call_ne

# 需要导入模块: from mock import mock [as 别名]
# 或者: from mock.mock import _Call [as 别名]
def test_call_ne(self):
        self.assertNotEqual(_Call(((1, 2, 3),)), call(1, 2))
        self.assertFalse(_Call(((1, 2, 3),)) != call(1, 2, 3))
        self.assertTrue(_Call(((1, 2), {})) != call(1, 2, 3)) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:6,代码来源:testhelpers.py

示例10: test_call_non_tuples

# 需要导入模块: from mock import mock [as 别名]
# 或者: from mock.mock import _Call [as 别名]
def test_call_non_tuples(self):
        kall = _Call(((1, 2, 3),))
        for value in 1, None, self, int:
            self.assertNotEqual(kall, value)
            self.assertFalse(kall == value) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:7,代码来源:testhelpers.py

示例11: test_repr

# 需要导入模块: from mock import mock [as 别名]
# 或者: from mock.mock import _Call [as 别名]
def test_repr(self):
        self.assertEqual(repr(_Call()), 'call()')
        self.assertEqual(repr(_Call(('foo',))), 'call.foo()')

        self.assertEqual(repr(_Call(((1, 2, 3), {'a': 'b'}))),
                         "call(1, 2, 3, a='b')")
        self.assertEqual(repr(_Call(('bar', (1, 2, 3), {'a': 'b'}))),
                         "call.bar(1, 2, 3, a='b')")

        self.assertEqual(repr(call), 'call')
        self.assertEqual(str(call), 'call')

        self.assertEqual(repr(call()), 'call()')
        self.assertEqual(repr(call(1)), 'call(1)')
        self.assertEqual(repr(call(zz='thing')), "call(zz='thing')")

        self.assertEqual(repr(call().foo), 'call().foo')
        self.assertEqual(repr(call(1).foo.bar(a=3).bing),
                         'call().foo.bar().bing')
        self.assertEqual(
            repr(call().foo(1, 2, a=3)),
            "call().foo(1, 2, a=3)"
        )
        self.assertEqual(repr(call()()), "call()()")
        self.assertEqual(repr(call(1)(2)), "call()(2)")
        self.assertEqual(
            repr(call()().bar().baz.beep(1)),
            "call()().bar().baz.beep(1)"
        ) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:31,代码来源:testhelpers.py

示例12: test_name_attribute_of_call

# 需要导入模块: from mock import mock [as 别名]
# 或者: from mock.mock import _Call [as 别名]
def test_name_attribute_of_call(self):
        # bpo-35357: _Call should not disclose any attributes whose names
        # may clash with popular ones (such as ".name")
        self.assertIsNotNone(call.name)
        self.assertEqual(type(call.name), _Call)
        self.assertEqual(type(call.name().name), _Call) 
开发者ID:testing-cabal,项目名称:mock,代码行数:8,代码来源:testmock.py

示例13: test_parent_attribute_of_call

# 需要导入模块: from mock import mock [as 别名]
# 或者: from mock.mock import _Call [as 别名]
def test_parent_attribute_of_call(self):
        # bpo-35357: _Call should not disclose any attributes whose names
        # may clash with popular ones (such as ".parent")
        self.assertIsNotNone(call.parent)
        self.assertEqual(type(call.parent), _Call)
        self.assertEqual(type(call.parent().parent), _Call) 
开发者ID:testing-cabal,项目名称:mock,代码行数:8,代码来源:testmock.py

示例14: test_named_call_with_args

# 需要导入模块: from mock import mock [as 别名]
# 或者: from mock.mock import _Call [as 别名]
def test_named_call_with_args(self):
        args = _Call(('foo', (1, 2, 3), {}))

        self.assertEqual(args, ('foo', (1, 2, 3)))
        self.assertEqual(args, ('foo', (1, 2, 3), {}))
        self.assertEqual(args.args, (1, 2, 3))
        self.assertEqual(args.kwargs, {})

        self.assertNotEqual(args, ((1, 2, 3),))
        self.assertNotEqual(args, ((1, 2, 3), {})) 
开发者ID:testing-cabal,项目名称:mock,代码行数:12,代码来源:testhelpers.py

示例15: test_call_with_kwargs

# 需要导入模块: from mock import mock [as 别名]
# 或者: from mock.mock import _Call [as 别名]
def test_call_with_kwargs(self):
        args = _Call(((), dict(a=3, b=4)))

        self.assertEqual(args, (dict(a=3, b=4),))
        self.assertEqual(args, ('foo', dict(a=3, b=4)))
        self.assertEqual(args, ('foo', (), dict(a=3, b=4)))
        self.assertEqual(args, ((), dict(a=3, b=4)))
        self.assertEqual(args.args, ())
        self.assertEqual(args.kwargs, dict(a=3, b=4)) 
开发者ID:testing-cabal,项目名称:mock,代码行数:11,代码来源:testhelpers.py


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