title: How to unit-test an event loop?
body: <p>I'm programming an HTTP proxy in Python (transparent proxy for request/response monitoring). But as a TDD adopter, I'm starting the project with HTTP inputs that should be caught by a TCP server. But, as any server, it must run within an event loop, so that it can listen in a specific port.</p>
  
  <p>Well, since starting the event loop will keep the interpreter inside the loop, after starting the server from a unit test, I cannot come back to the test to send an HTTP request to this server.</p>
  
  <p>What do you guys recommend me to design so that I can run the server and come back to the unit test to test it? Use threads? Zero-timeouts?</p>
  
  <p>Thanks!</p>
  
  <p>Diogo</p>