facebook/tornado — pull request #590 by davidmarin (2012-08-29 00:33:12+00:00)
Title: Let socket find an unused port

At Yelp, we were running into an issue where a real server was on one of the "hopefully open" ports Tornado uses for testing.

`socket.bind()` can pick an unused port for you if you specify `0` as the port number. This change lets the socket find an unused port, which is then stored and passed through to `tornado.testing.AsyncHTTPTestCase.get_url()`.

`tornado.testing.get_unused_port()` is used in other places, but it's probably best to get rid of it, as it doesn't actually do what it advertises. I'm just fixing `AsyncHTTPTestCase` in this change though. :)