While we have seen how to test client without connecting to a real server, we can't rely only on faked messages to confirm that our application works. If we are going to change server responses, the tests wouldn't even notice and would continue to pass while in reality, the client has stopped working. How can we detect those kinds of issues without involving real networking? The WSGI (Web Server Gateway Interface) protocol and WebTest library come in hand to do exactly that, set up a client-server communication that involves no networking at all.
When we create web applications in Python, the most frequent way they work is through an application server. The application server will be the one receiving HTTP requests, decoding them, and forwarding them to the real web application. Forwarding those requests to the web application and receiving back responses via the WSGI protocol is usually the communication channel of choice for Python.
The WSGI protocol...