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


Python mock._Call函数代码示例

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


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

示例1: test_repr

    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:D3f0,项目名称:pinguinoweb,代码行数:29,代码来源:testhelpers.py

示例2: test_two_args_call

 def test_two_args_call(self):
     args = _Call(((1, 2), {'a': 3}), two=True)
     self.assertEqual(len(args), 2)
     self.assertEqual(args[0], (1, 2))
     self.assertEqual(args[1], {'a': 3})
     other_args = _Call(((1, 2), {'a': 3}))
     self.assertEqual(args, other_args)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:testhelpers.py

示例3: test_call_with_name

 def test_call_with_name(self):
     self.assertEqual(
         'foo',
         _Call((), 'foo')[0],
     )
     self.assertEqual(
         '',
         _Call((('bar', 'barz'), ), )[0]
     )
     self.assertEqual(
         '',
         _Call((('bar', 'barz'), {'hello': 'world'}), )[0]
     )
开发者ID:FRidh,项目名称:cpython,代码行数:13,代码来源:testhelpers.py

示例4: test_call_with_kwargs

    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)))
开发者ID:D3f0,项目名称:pinguinoweb,代码行数:7,代码来源:testhelpers.py

示例5: test_call_with_args

    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:D3f0,项目名称:pinguinoweb,代码行数:7,代码来源:testhelpers.py

示例6: test_empty__Call

 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:johndpope,项目名称:sims4-ai-engine,代码行数:9,代码来源:testhelpers.py

示例7: test_named_empty_call

 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:johndpope,项目名称:sims4-ai-engine,代码行数:12,代码来源:testhelpers.py

示例8: test_call_with_call

    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:D3f0,项目名称:pinguinoweb,代码行数:35,代码来源:testhelpers.py

示例9: test_call_non_tuples

 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:D3f0,项目名称:pinguinoweb,代码行数:5,代码来源:testhelpers.py

示例10: test_call_ne

 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:D3f0,项目名称:pinguinoweb,代码行数:4,代码来源:testhelpers.py

示例11: test_call_with_args_call_empty_name

 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.assertTrue(call(1, 2, 3) in [args])
开发者ID:D3f0,项目名称:pinguinoweb,代码行数:5,代码来源:testhelpers.py


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