I'm writing a REST client and I need to mock a HTTP server in my tests. What would be the most appropriate library to do that? It would be great if I could create expected HTTP requests and compare them to actual.
get() should return a mock for the response. To mock the response, you can use the MagicMock class of the unittest. mock module.
What is MockServer. For any system you integrate with via HTTP or HTTPS MockServer can be used as: a mock configured to return specific responses for different requests. a proxy recording and optionally modifying requests and responses. both a proxy for some requests and a mock for other requests at the same time.
Try HTTPretty, a HTTP client mock library for Python helps you focus on the client side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With