Fix Transport, DatagramTransport mockup issues.

This commit is contained in:
Jonathan Moody 2022-06-16 12:37:00 -04:00 committed by Lex Berezhny
parent 7a86406746
commit ea4fba39a6

View file

@ -61,7 +61,6 @@ def mock_network_loop(loop: asyncio.AbstractEventLoop,
dht_network[from_addr] = protocol dht_network[from_addr] = protocol
return transport, protocol return transport, protocol
with mock.patch('socket.socket') as mock_socket:
mock_sock = mock.Mock(spec=socket.socket) mock_sock = mock.Mock(spec=socket.socket)
mock_sock.setsockopt = lambda *_: None mock_sock.setsockopt = lambda *_: None
mock_sock.bind = lambda *_: None mock_sock.bind = lambda *_: None
@ -71,6 +70,5 @@ def mock_network_loop(loop: asyncio.AbstractEventLoop,
mock_sock.close = lambda: None mock_sock.close = lambda: None
mock_sock.type = socket.SOCK_DGRAM mock_sock.type = socket.SOCK_DGRAM
mock_sock.fileno = lambda: 7 mock_sock.fileno = lambda: 7
mock_socket.return_value = mock_sock
loop.create_datagram_endpoint = create_datagram_endpoint loop.create_datagram_endpoint = create_datagram_endpoint
yield yield