本文整理汇总了Python中pungi.spyOn函数的典型用法代码示例。如果您正苦于以下问题:Python spyOn函数的具体用法?Python spyOn怎么用?Python spyOn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spyOn函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_explict_declaration_of_raise_exception
def test_explict_declaration_of_raise_exception(self):
obj = TempClass()
spyOn(obj, 'hello')
obj.hello.raiseException = Exception
self.assertRaises(Exception, obj.hello)
开发者ID:endeepak,项目名称:pungi,代码行数:7,代码来源:test_spy_method.py
示例2: test_most_recent_call_kwargs
def test_most_recent_call_kwargs(self):
obj = TempClass()
spyOn(obj, 'hello')
obj.hello(say="hello")
self.assertEqual(obj.hello.mostRecentCall.kwargs, dict(say="hello"))
开发者ID:endeepak,项目名称:pungi,代码行数:7,代码来源:test_spy_method.py
示例3: test_was_called_after_call
def test_was_called_after_call(self):
obj = TempClass()
spyOn(obj, 'hello')
obj.hello()
self.assertTrue(obj.hello.wasCalled())
开发者ID:endeepak,项目名称:pungi,代码行数:7,代码来源:test_spy_method.py
示例4: test_stop
def test_stop(self):
obj = TempClass()
spyOn(obj, 'hello', returnValue="spy says hello")
spy.Method.stop()
self.assertEqual(obj.hello(), "hello")
开发者ID:endeepak,项目名称:pungi,代码行数:7,代码来源:test_spy_method.py
示例5: test_explicit_return_value
def test_explicit_return_value(self):
obj = TempClass()
spyOn(obj, 'hello')
obj.hello.returnValue = "spy says hello"
self.assertEqual(obj.hello(), "spy says hello")
开发者ID:endeepak,项目名称:pungi,代码行数:7,代码来源:test_spy_method.py
示例6: test_most_recent_call_args
def test_most_recent_call_args(self):
obj = TempClass()
spyOn(obj, 'hello')
obj.hello("h", "e", "l", "l", "o")
self.assertEqual(obj.hello.mostRecentCall.args,
("h", "e", "l", "l", "o"))
开发者ID:endeepak,项目名称:pungi,代码行数:8,代码来源:test_spy_method.py
示例7: test_call_count_after_call
def test_call_count_after_call(self):
obj = TempClass()
spyOn(obj, 'hello')
obj.hello()
obj.hello()
self.assertEqual(obj.hello.callCount, 2)
开发者ID:endeepak,项目名称:pungi,代码行数:8,代码来源:test_spy_method.py
示例8: test_was_called_times
def test_was_called_times(self):
obj = TempClass()
spyOn(obj, 'hello')
obj.hello()
obj.hello()
self.assertTrue(obj.hello.wasCalled(times=2))
开发者ID:endeepak,项目名称:pungi,代码行数:8,代码来源:test_spy_method.py
示例9: test_toHaveBeenCalledTimes
def test_toHaveBeenCalledTimes(self):
obj = TempClass()
spyOn(obj, "hello")
obj.hello()
obj.hello()
expect(obj.hello).toHaveBeenCalled(times=2)
self.assertRaises(AssertionError, expect(obj.hello).toHaveBeenCalled, times=1)
开发者ID:endeepak,项目名称:pungi,代码行数:9,代码来源:test_matchers.py
示例10: test_kwargs_for_call
def test_kwargs_for_call(self):
obj = TempClass()
spyOn(obj, 'hello')
obj.hello(say="hello")
obj.hello(to="world")
self.assertEqual(obj.hello.kwargsForCall(0), dict(say="hello"))
self.assertEqual(obj.hello.kwargsForCall(1), dict(to="world"))
开发者ID:endeepak,项目名称:pungi,代码行数:9,代码来源:test_spy_method.py
示例11: test_args_for_call
def test_args_for_call(self):
obj = TempClass()
spyOn(obj, 'hello')
obj.hello("h", "e")
obj.hello("l", "l", "o")
self.assertEqual(obj.hello.argsForCall(0), ("h", "e"))
self.assertEqual(obj.hello.argsForCall(1), ("l", "l", "o"))
开发者ID:endeepak,项目名称:pungi,代码行数:9,代码来源:test_spy_method.py
示例12: test_method_chaining
def test_method_chaining(self):
obj = TempClass()
spyOn(obj, 'hello')
obj.hello().world().wassup()
self.assertEqual(obj.hello.callCount, 1)
self.assertEqual(obj.hello().world.callCount, 1)
self.assertEqual(obj.hello().world().wassup.callCount, 1)
开发者ID:endeepak,项目名称:pungi,代码行数:9,代码来源:test_spy_method.py
示例13: test_call_through_for_andCallThrough_syntax
def test_call_through_for_andCallThrough_syntax(self):
obj = TempClass()
spyOn(obj, 'hello').andCallThrough()
spyOn(obj, 'hello_world').andCallThrough()
self.assertEqual(obj.hello(), "hello")
self.assertEqual(obj.hello.callCount, 1)
self.assertEqual(obj.hello_world("hello world"), "hello world")
self.assertEqual(obj.hello_world.callCount, 1)
开发者ID:endeepak,项目名称:pungi,代码行数:10,代码来源:test_spy_method.py
示例14: test_call_through
def test_call_through(self):
obj = TempClass()
spyOn(obj, 'hello', callThrough=True)
spyOn(obj, 'hello_world', callThrough=True)
self.assertEqual(obj.hello(), "hello")
self.assertEqual(obj.hello.callCount, 1)
self.assertEqual(obj.hello_world("hello world"), "hello world")
self.assertEqual(obj.hello_world.callCount, 1)
开发者ID:endeepak,项目名称:pungi,代码行数:10,代码来源:test_spy_method.py
示例15: test_was_called_with
def test_was_called_with(self):
obj = TempClass()
spyOn(obj, 'hello')
obj.hello(1)
obj.hello(1, to=2)
self.assertTrue(obj.hello.wasCalledWith(1))
self.assertTrue(obj.hello.wasCalledWith(1, to=2))
self.assertFalse(obj.hello.wasCalledWith(2))
开发者ID:endeepak,项目名称:pungi,代码行数:10,代码来源:test_spy_method.py
示例16: test_was_called_before
def test_was_called_before(self):
obj = TempClass()
spyOn(obj, 'hello')
spyOn(obj, 'hi')
obj.hi()
obj.hello()
self.assertTrue(obj.hi.wasCalledBefore(obj.hello))
self.assertFalse(obj.hello.wasCalledBefore(obj.hi))
开发者ID:endeepak,项目名称:pungi,代码行数:10,代码来源:test_spy_method.py
示例17: test_toHaveBeenCalled
def test_toHaveBeenCalled(self):
obj = TempClass()
spyOn(obj, "hello")
spyOn(obj, "hi")
obj.hello()
expect(obj.hello).toHaveBeenCalled()
expect(obj.hi).notToHaveBeenCalled()
self.assertRaises(AssertionError, expect(obj.hello).notToHaveBeenCalled)
self.assertRaises(AssertionError, expect(obj.hi).toHaveBeenCalled)
开发者ID:endeepak,项目名称:pungi,代码行数:11,代码来源:test_matchers.py
示例18: test_toHaveBeenCalledBefore
def test_toHaveBeenCalledBefore(self):
obj = TempClass()
spyOn(obj, 'hello')
spyOn(obj, 'hi')
obj.hi()
obj.hello()
expect(obj.hi).toHaveBeenCalledBefore(obj.hello)
expect(obj.hello).notToHaveBeenCalledBefore(obj.hi)
self.assertRaises(AssertionError,
expect(obj.hi).notToHaveBeenCalledBefore, obj.hello)
self.assertRaises(AssertionError,
expect(obj.hello).toHaveBeenCalledBefore, obj.hi)
开发者ID:logeen,项目名称:pungi,代码行数:15,代码来源:test_matchers.py
示例19: test_spy_is_rolled_back_outside_the_with_block
def test_spy_is_rolled_back_outside_the_with_block(self):
obj = TempClass()
with spyOn(obj, 'hello', returnValue="spy says hello"):
pass
self.assertEqual(obj.hello(), "hello")
开发者ID:endeepak,项目名称:pungi,代码行数:7,代码来源:test_spy_method.py
示例20: test_toHaveBeenCalledWith
def test_toHaveBeenCalledWith(self):
obj = TempClass()
spyOn(obj, "hello")
spyOn(obj, "hi")
obj.hello(1, to=2)
expect(obj.hello).toHaveBeenCalledWith(1, to=2)
expect(obj.hello).toHaveBeenCalledWith(1, to=any(int))
expect(obj.hello).toHaveBeenCalledWith(any(int), to=2)
expect(obj.hello).toHaveBeenCalledWith(any(int), to=any(int))
expect(obj.hi).notToHaveBeenCalledWith(1, to=2)
expect(obj.hi).notToHaveBeenCalledWith(any(bool), to=any(bool))
self.assertRaises(AssertionError, expect(obj.hello).notToHaveBeenCalledWith, 1, to=2)
self.assertRaises(AssertionError, expect(obj.hello).notToHaveBeenCalledWith, any(int), to=any(int))
self.assertRaises(AssertionError, expect(obj.hi).toHaveBeenCalledWith, 1, to=2)
self.assertRaises(AssertionError, expect(obj.hi).toHaveBeenCalledWith, any(bool), to=any(bool))
开发者ID:endeepak,项目名称:pungi,代码行数:17,代码来源:test_matchers.py
注:本文中的pungi.spyOn函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论