O'Reilly logo

Python Requests Essentials by Bala Subrahmanyam Varanasi, Rakesh Vidya Chandra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Mocking HTTP Requests Using HTTPretty

With the Requests module, we gained the means to open URLs, post data, and get data from web services. Let us take an instance of building an application, which uses a RESTful API and unfortunately, the API on which the server is running is down. Even though we achieved interaction with the web using Requests, we failed this time because we got no response from the server's side. This condition may leave us irked and blocked from our progress, as we found no way of testing our code any further.

So, there came this idea of creating an HTTP request mock tool, which can serve us by mocking the web server on the client side. Even though HTTPretty is no way directly connected with Requests, we would like ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required