Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Switching from get_unused_port to bind_unused_port in ClientTextMixin class. #676

Closed
wants to merge 1 commit into from

2 participants

@jpittman

bind_unused_port guarantees that it will find an unused port for testing purposes. get_unused_port was causing tests to fail due to a port already being in use on a development machine (in this case, a mac running osx 10.8).

@jpittman jpittman Switching from get_unused_port to bind_unused_port in ClientTextMixin…
… class.

bind_unused_port guarantees that it will find an unused port for testing purposes.  get_unused_port was causing tests to fail due to a port already being in use on a development machine (in this case, a mac running osx 10.8).
27f7bd6
@bdarnell bdarnell closed this in 172e095
@bdarnell
Owner

Whoops, I thought I had fixed all of those. Anyway, as the CI build shows, you need to actually use the socket returned by bind_unused_port, since it won't be available if you just try to bind it again. I'll make a separate commit with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 5, 2013
  1. @jpittman

    Switching from get_unused_port to bind_unused_port in ClientTextMixin…

    jpittman authored
    … class.
    
    bind_unused_port guarantees that it will find an unused port for testing purposes.  get_unused_port was causing tests to fail due to a port already being in use on a development machine (in this case, a mac running osx 10.8).
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 2 deletions.
  1. +3 −2 tornado/test/concurrent_test.py
View
5 tornado/test/concurrent_test.py
@@ -24,7 +24,7 @@
from tornado import gen
from tornado.iostream import IOStream
from tornado.tcpserver import TCPServer
-from tornado.testing import AsyncTestCase, LogTrapTestCase, get_unused_port, gen_test
+from tornado.testing import AsyncTestCase, LogTrapTestCase, bind_unused_port, gen_test
class ReturnFutureTest(AsyncTestCase):
@@ -206,7 +206,8 @@ class ClientTestMixin(object):
def setUp(self):
super(ClientTestMixin, self).setUp()
self.server = CapServer(io_loop=self.io_loop)
- port = get_unused_port()
+ # bind_unused_port returns a tuple. the second entry is the port number.
+ port = bind_unused_port()[1]
self.server.listen(port, address='127.0.0.1')
self.client = self.client_class(io_loop=self.io_loop, port=port)
Something went wrong with that request. Please try again.