(self)
| 2123 | self.assertEqual(s2.fileno(), fd) |
| 2124 | |
| 2125 | def test_socket_fileno(self): |
| 2126 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
| 2127 | self.addCleanup(s.close) |
| 2128 | s.bind((socket_helper.HOST, 0)) |
| 2129 | self._test_socket_fileno(s, socket.AF_INET, socket.SOCK_STREAM) |
| 2130 | |
| 2131 | if hasattr(socket, "SOCK_DGRAM"): |
| 2132 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) |
| 2133 | self.addCleanup(s.close) |
| 2134 | s.bind((socket_helper.HOST, 0)) |
| 2135 | self._test_socket_fileno(s, socket.AF_INET, socket.SOCK_DGRAM) |
| 2136 | |
| 2137 | if socket_helper.IPV6_ENABLED: |
| 2138 | s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) |
| 2139 | self.addCleanup(s.close) |
| 2140 | s.bind((socket_helper.HOSTv6, 0, 0, 0)) |
| 2141 | self._test_socket_fileno(s, socket.AF_INET6, socket.SOCK_STREAM) |
| 2142 | |
| 2143 | if hasattr(socket, "AF_UNIX"): |
| 2144 | unix_name = socket_helper.create_unix_domain_name() |
| 2145 | self.addCleanup(os_helper.unlink, unix_name) |
| 2146 | |
| 2147 | s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) |
| 2148 | with s: |
| 2149 | try: |
| 2150 | s.bind(unix_name) |
| 2151 | except PermissionError: |
| 2152 | pass |
| 2153 | else: |
| 2154 | self._test_socket_fileno(s, socket.AF_UNIX, |
| 2155 | socket.SOCK_STREAM) |
| 2156 | |
| 2157 | def test_socket_fileno_rejects_float(self): |
| 2158 | with self.assertRaises(TypeError): |
nothing calls this directly
no test coverage detected