diff --git a/tests/dht_mocks.py b/tests/dht_mocks.py index cf303215c..1d10b3039 100644 --- a/tests/dht_mocks.py +++ b/tests/dht_mocks.py @@ -61,16 +61,14 @@ def mock_network_loop(loop: asyncio.AbstractEventLoop, dht_network[from_addr] = protocol return transport, protocol - with mock.patch('socket.socket') as mock_socket: - mock_sock = mock.Mock(spec=socket.socket) - mock_sock.setsockopt = lambda *_: None - mock_sock.bind = lambda *_: None - mock_sock.setblocking = lambda *_: None - mock_sock.getsockname = lambda: "0.0.0.0" - mock_sock.getpeername = lambda: "" - mock_sock.close = lambda: None - mock_sock.type = socket.SOCK_DGRAM - mock_sock.fileno = lambda: 7 - mock_socket.return_value = mock_sock - loop.create_datagram_endpoint = create_datagram_endpoint - yield + mock_sock = mock.Mock(spec=socket.socket) + mock_sock.setsockopt = lambda *_: None + mock_sock.bind = lambda *_: None + mock_sock.setblocking = lambda *_: None + mock_sock.getsockname = lambda: "0.0.0.0" + mock_sock.getpeername = lambda: "" + mock_sock.close = lambda: None + mock_sock.type = socket.SOCK_DGRAM + mock_sock.fileno = lambda: 7 + loop.create_datagram_endpoint = create_datagram_endpoint + yield