Comment 1 for bug 1650858

Revision history for this message
Jamie Lennox (jamielennox) wrote :

So yea, the error I think is fairly explanatory that timeout isn't a vaild argument. I'm not sure i would want to add it either, adding a pause for a web response is a fairly unusual situation for a unit test as you'll be stuck waiting for the pause.

You can however do it yourself pretty easily.

In times I've wanted to test an actual timeout i've done

m.head('https://www.google.com', exc=requests.Timeout)

which will trigger the same exception requests does when it times out. If you actually want to wait you could do:

def response_wait(request, context):
    time.sleep(15)
    return u''

m.head('https://www.google.com', text=response_wait, status_code=404)

More on dynamic responses: http://requests-mock.readthedocs.io/en/latest/response.html#dynamic-response

Does that satisfy your question?