Skip to content

Commit 0403d56

Browse files
Add test_socket_module_has_signatures()
1 parent fb7fffb commit 0403d56

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lib/test/test_inspect/test_inspect.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6312,6 +6312,24 @@ def test_signal_module_has_signatures(self):
63126312
import signal
63136313
self._test_module_has_signatures(signal)
63146314

6315+
def test_socket_module_has_signatures(self):
6316+
import socket
6317+
# The socket type has no signature, it is created by socket().
6318+
no_signature = {'SocketType'}
6319+
# The C default is NULL and None is not accepted
6320+
unsupported_signature = {'getservbyname', 'getservbyport'}
6321+
# These cannot be converted to Argument Clinic: their behaviour
6322+
# depends on the number of the arguments.
6323+
methods_no_signature = {'ioctl', 'sendto', 'setsockopt'}
6324+
# These have parameters with unrepresentable default values.
6325+
methods_unsupported_signature = {'listen', 'sendmsg', 'sendmsg_afalg'}
6326+
# Not all methods are available on all platforms.
6327+
defined = vars(socket.SocketType).keys()
6328+
self._test_module_has_signatures(socket,
6329+
no_signature, unsupported_signature,
6330+
{'SocketType': methods_no_signature & defined},
6331+
{'SocketType': methods_unsupported_signature & defined})
6332+
63156333
def test_stat_module_has_signatures(self):
63166334
import stat
63176335
self._test_module_has_signatures(stat)

0 commit comments

Comments
 (0)