[关闭]
@songying 2018-07-18T21:40:16.000000Z 字数 656 阅读 1104

unittest.mock

unittest


https://docs.python.org/3.4/library/unittest.mock.html

https://docs.python.org/3.4/library/unittest.mock-examples.html

Mock

Mock 类

  1. class unittest.mock.Mock(spec=None, side_effect=None, return_value=DEFAULT, wraps=None, name=None, spec_set=None, **kwargs)
  • spec:
  • spec_set:

assert_called_with()

  1. assert_called_with(*args, **kwargs)

assert_called_once_with()

  1. assert_called_once_with(*args, **kwargs)

assert_any_call()

  1. assert_any_call(*args, **kwargs)

assert_has_calls()

  1. assert_has_calls(calls, any_order=False)

reset_mock()

configure_mock()

the patchers

  1. unittest.mock.patch(target, new=DEFAULT, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs)
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注