Permalink
Browse files

make http_reporter_test compatible with tornado 2.x

  • Loading branch information...
1 parent 55098a7 commit c1e159fe0e668a1ee56b0b1b2858c0a0becf20a0 @blampe committed Apr 5, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 test/plugins/http_reporter_test.py
@@ -39,7 +39,7 @@ def get_error_html(handler, status, **kwargs ):
app = tornado.web.Application([(r"/results", ResultsHandler)])
srv = tornado.httpserver.HTTPServer(app)
srv.listen(0)
- portnum = srv._socket.getsockname()[1]
+ portnum = self.get_port_number(srv)
iol = tornado.ioloop.IOLoop.instance()
thread = threading.Thread(target=iol.start)
@@ -53,6 +53,13 @@ def get_error_html(handler, status, **kwargs ):
iol.stop()
thread.join()
+ def get_port_number(self, server):
+ if hasattr(server, "_sockets"): # tornado > 2.0
+ _socket = server._sockets.values()[0]
+ else: # tornado 1.2 or earlier
+ _socket = server._socket
+ return _socket.getsockname()[1]
+
def test_http_reporter_reports(self):
"""A simple test to make sure the HTTPReporter actually reports things."""
@@ -74,4 +81,5 @@ def test_http_reporter_tries_twice(self):
(first, second) = self.results_reported
assert_equal(first['runner_id'], 'tries_twice')
- assert_equal(first, second)
+ assert_equal(first, second)
+

0 comments on commit c1e159f

Please sign in to comment.