我在我的单元测试中使用 requests_mock 并且想模拟 response.elapsed 属性但没有找到正确的方法来做到这一点。刚刚找到了将睡眠添加到文本回调的解决方法。
with requests_mock.mock() as m:
def text_callback_with_delay(request, context):
time.sleep(2)
return "{}"
m.get(GET_REQUEST_URL, text=text_callback_with_delay)
有没有更好的方法来模拟response.elapsed使用requests_mock?