MCPcopy Index your code
hub / github.com/python/cpython / test_is_socket_true

Method test_is_socket_true

Lib/test/test_pathlib/test_pathlib.py:2753–2767  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2751 is_wasi, "Cannot create socket on WASI."
2752 )
2753 def test_is_socket_true(self):
2754 P = self.cls(self.base, 'mysock')
2755 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
2756 self.addCleanup(sock.close)
2757 try:
2758 sock.bind(str(P))
2759 except OSError as e:
2760 if (isinstance(e, PermissionError) or
2761 "AF_UNIX path too long" in str(e)):
2762 self.skipTest("cannot bind Unix socket: " + str(e))
2763 self.assertTrue(P.is_socket())
2764 self.assertFalse(P.is_fifo())
2765 self.assertFalse(P.is_file())
2766 self.assertIs(self.cls(self.base, 'mysock\udfff').is_socket(), False)
2767 self.assertIs(self.cls(self.base, 'mysock\x00').is_socket(), False)
2768
2769 def test_is_block_device_false(self):
2770 P = self.cls(self.base)

Callers

nothing calls this directly

Calls 12

strFunction · 0.85
socketMethod · 0.80
addCleanupMethod · 0.80
skipTestMethod · 0.80
assertTrueMethod · 0.80
is_socketMethod · 0.80
assertFalseMethod · 0.80
is_fifoMethod · 0.80
clsMethod · 0.45
bindMethod · 0.45
is_fileMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected