Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mocking a HTTP server in Python

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.

like image 292
prasopes Avatar asked Feb 19 '14 10:02

prasopes


People also ask

How do you use mock HTTP response in Python?

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 a HTTP mock server?

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.


1 Answers

Try HTTPretty, a HTTP client mock library for Python helps you focus on the client side.

like image 164
clsung Avatar answered Sep 18 '22 15:09

clsung