MCPcopy Index your code
hub / github.com/RustPython/RustPython / mock_socket_module

Function mock_socket_module

Lib/test/test_asyncio/test_base_events.py:35–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33
34
35def mock_socket_module():
36 m_socket = mock.MagicMock(spec=socket)
37 for name in (
38 'AF_INET', 'AF_INET6', 'AF_UNSPEC', 'IPPROTO_TCP', 'IPPROTO_UDP',
39 'SOCK_STREAM', 'SOCK_DGRAM', 'SOL_SOCKET', 'SO_REUSEADDR', 'inet_pton'
40 ):
41 if hasattr(socket, name):
42 setattr(m_socket, name, getattr(socket, name))
43 else:
44 delattr(m_socket, name)
45
46 m_socket.socket = mock.MagicMock()
47 m_socket.socket.return_value = test_utils.mock_nonblocking_socket()
48
49 return m_socket
50
51
52def patch_socket(f):

Callers

nothing calls this directly

Calls 4

hasattrFunction · 0.85
setattrFunction · 0.85
getattrFunction · 0.85
delattrFunction · 0.85

Tested by

no test coverage detected