|
|
|
@ -1,4 +1,3 @@
|
|
|
|
|
import functools
|
|
|
|
|
import io
|
|
|
|
|
import os
|
|
|
|
|
import socket
|
|
|
|
@ -74,26 +73,27 @@ def test_handle():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_server_thread():
|
|
|
|
|
connections = [FakeSocket()]
|
|
|
|
|
sock = FakeSocket()
|
|
|
|
|
connections = [sock]
|
|
|
|
|
quit_event = threading.Event()
|
|
|
|
|
|
|
|
|
|
class FakeServer(object):
|
|
|
|
|
def accept(self): # pylint: disable=no-self-use
|
|
|
|
|
if connections:
|
|
|
|
|
return connections.pop(), 'address'
|
|
|
|
|
quit_event.set()
|
|
|
|
|
raise socket.timeout()
|
|
|
|
|
|
|
|
|
|
def getsockname(self): # pylint: disable=no-self-use
|
|
|
|
|
return 'fake_server'
|
|
|
|
|
|
|
|
|
|
handler = protocol.Handler(conn=empty_device()),
|
|
|
|
|
handle_conn = functools.partial(server.handle_connection,
|
|
|
|
|
handler=handler,
|
|
|
|
|
mutex=None)
|
|
|
|
|
def handle_conn(conn):
|
|
|
|
|
assert conn is sock
|
|
|
|
|
quit_event.set()
|
|
|
|
|
|
|
|
|
|
server.server_thread(sock=FakeServer(),
|
|
|
|
|
handle_conn=handle_conn,
|
|
|
|
|
quit_event=quit_event)
|
|
|
|
|
quit_event.wait()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_spawn():
|
|
|
|
|