擅长:python、mysql、java
<p>在Python中“模拟”函数调用的最好方法是使用<a href="http://www.voidspace.org.uk/python/mock/index.html" rel="nofollow">mock</a>库。另外,如果您使用<a href="http://nose.readthedocs.org/en/latest/" rel="nofollow">nose</a>作为单元测试框架,那么一个值得考虑的插件是<a href="https://github.com/andymckay/nose-blockage" rel="nofollow">nose-blockage</a>,它可以确保如果您的测试没有正确地模拟出所有内容,就不会有API调用通过。在</p>