84 lines
3.2 KiB
Diff
84 lines
3.2 KiB
Diff
|
From f8c3e96df731eccda202e0dc909f0a51cdc41267 Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
|
||
|
Date: Sat, 14 Jul 2018 12:21:50 +0200
|
||
|
Subject: [PATCH 1/2] dummyserver: Update for tornado-5 API changes
|
||
|
|
||
|
Tornado 5 has apparently removed support for multiple IOLoops,
|
||
|
and appropriately removed the io_loop parameter to the server class
|
||
|
in favor of using IOLoop.current(). Update the tests to use the latter.
|
||
|
The code remains compatible with tornado-4.
|
||
|
---
|
||
|
dummyserver/server.py | 9 +++++----
|
||
|
dummyserver/testcase.py | 4 ++--
|
||
|
2 files changed, 7 insertions(+), 6 deletions(-)
|
||
|
|
||
|
Index: urllib3-1.23/dummyserver/server.py
|
||
|
===================================================================
|
||
|
--- urllib3-1.23.orig/dummyserver/server.py
|
||
|
+++ urllib3-1.23/dummyserver/server.py
|
||
|
@@ -226,15 +226,16 @@ def bind_sockets(port, address=None, fam
|
||
|
|
||
|
|
||
|
def run_tornado_app(app, io_loop, certs, scheme, host):
|
||
|
+ assert io_loop == tornado.ioloop.IOLoop.current()
|
||
|
+
|
||
|
# We can't use fromtimestamp(0) because of CPython issue 29097, so we'll
|
||
|
# just construct the datetime object directly.
|
||
|
app.last_req = datetime(1970, 1, 1)
|
||
|
|
||
|
if scheme == 'https':
|
||
|
- http_server = tornado.httpserver.HTTPServer(app, ssl_options=certs,
|
||
|
- io_loop=io_loop)
|
||
|
+ http_server = tornado.httpserver.HTTPServer(app, ssl_options=certs)
|
||
|
else:
|
||
|
- http_server = tornado.httpserver.HTTPServer(app, io_loop=io_loop)
|
||
|
+ http_server = tornado.httpserver.HTTPServer(app)
|
||
|
|
||
|
sockets = bind_sockets(None, address=host)
|
||
|
port = sockets[0].getsockname()[1]
|
||
|
@@ -268,7 +269,7 @@ if __name__ == '__main__':
|
||
|
from .testcase import TestingApp
|
||
|
host = '127.0.0.1'
|
||
|
|
||
|
- io_loop = tornado.ioloop.IOLoop()
|
||
|
+ io_loop = tornado.ioloop.IOLoop.current()
|
||
|
app = tornado.web.Application([(r".*", TestingApp)])
|
||
|
server, port = run_tornado_app(app, io_loop, None,
|
||
|
'http', host)
|
||
|
Index: urllib3-1.23/dummyserver/testcase.py
|
||
|
===================================================================
|
||
|
--- urllib3-1.23.orig/dummyserver/testcase.py
|
||
|
+++ urllib3-1.23/dummyserver/testcase.py
|
||
|
@@ -124,7 +124,7 @@ class HTTPDummyServerTestCase(unittest.T
|
||
|
|
||
|
@classmethod
|
||
|
def _start_server(cls):
|
||
|
- cls.io_loop = ioloop.IOLoop()
|
||
|
+ cls.io_loop = ioloop.IOLoop.current()
|
||
|
app = web.Application([(r".*", TestingApp)])
|
||
|
cls.server, cls.port = run_tornado_app(app, cls.io_loop, cls.certs,
|
||
|
cls.scheme, cls.host)
|
||
|
@@ -170,7 +170,7 @@ class HTTPDummyProxyTestCase(unittest.Te
|
||
|
|
||
|
@classmethod
|
||
|
def setUpClass(cls):
|
||
|
- cls.io_loop = ioloop.IOLoop()
|
||
|
+ cls.io_loop = ioloop.IOLoop.current()
|
||
|
|
||
|
app = web.Application([(r'.*', TestingApp)])
|
||
|
cls.http_server, cls.http_port = run_tornado_app(
|
||
|
Index: urllib3-1.23/dev-requirements.txt
|
||
|
===================================================================
|
||
|
--- urllib3-1.23.orig/dev-requirements.txt
|
||
|
+++ urllib3-1.23/dev-requirements.txt
|
||
|
@@ -3,7 +3,8 @@ coverage==3.7.1
|
||
|
tox==2.1.1
|
||
|
twine==1.5.0
|
||
|
wheel==0.24.0
|
||
|
-tornado==4.2.1
|
||
|
+tornado==5.0.2; python_version>"2.6"
|
||
|
+tornado==4.2.1; python_version<="2.6"
|
||
|
PySocks==1.5.6
|
||
|
pkginfo>=1.0,!=1.3.0
|
||
|
psutil==4.3.1
|