Fix test_wsgi.py tests failing with eventlet <=0.18.4
Older versions of eventlet expect getsocketname() to return a tuple, and newer versions are happy to receive a tuple, so fix the mock to return a tuple. Change-Id: I68fd9d0263a6720aaf0d90b8ea6da1158105ac01 Closes-Bug: #1777701
This commit is contained in:
parent
fd76a1b380
commit
642d8748c0
@ -1106,15 +1106,19 @@ class TestProxyProtocol(unittest.TestCase):
|
||||
]) + '\r\n'
|
||||
return [body.encode("utf-8")]
|
||||
|
||||
addr = ('127.0.0.1', 8359)
|
||||
fake_tcp_socket = mock.Mock(
|
||||
setsockopt=lambda *a: None,
|
||||
makefile=lambda mode, bufsize: rfile if 'r' in mode else wfile,
|
||||
getsockname=lambda *a: addr
|
||||
)
|
||||
fake_listen_socket = mock.Mock(accept=mock.MagicMock(
|
||||
side_effect=[[fake_tcp_socket, ('127.0.0.1', 8359)],
|
||||
# KeyboardInterrupt breaks the WSGI server out of
|
||||
# its infinite accept-process-close loop.
|
||||
KeyboardInterrupt]))
|
||||
fake_listen_socket = mock.Mock(
|
||||
accept=mock.MagicMock(
|
||||
side_effect=[[fake_tcp_socket, addr],
|
||||
# KeyboardInterrupt breaks the WSGI server out of
|
||||
# its infinite accept-process-close loop.
|
||||
KeyboardInterrupt]),
|
||||
getsockname=lambda *a: addr)
|
||||
del fake_listen_socket.do_handshake
|
||||
|
||||
# If we let the WSGI server close rfile/wfile then we can't access
|
||||
|
Loading…
x
Reference in New Issue
Block a user