我需要测试一个需要使用urllib.urlopen在外部服务器上查询页面的函数(它还使用urllib.urlencode).服务器可能已关闭,页面可能会更改; 我不能依靠它进行测试.
控制urllib.urlopen返回的最佳方法是什么?
python testing unit-testing mocking
mocking ×1
python ×1
testing ×1
unit-testing ×1