mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #1746656: Add if_nameindex, if_nametoindex, if_indextoname
methods to the socket module.
This commit is contained in:
parent
1a4de20d95
commit
5ed2e779f1
7 changed files with 429 additions and 248 deletions
|
@ -372,6 +372,16 @@ class GeneralModuleTests(unittest.TestCase):
|
|||
finally:
|
||||
socket.sethostname(oldhn)
|
||||
|
||||
@unittest.skipUnless(hasattr(socket, 'if_nameindex'),
|
||||
'socket.if_nameindex() not available.')
|
||||
def testInterfaceNameIndex(self):
|
||||
interfaces = socket.if_nameindex()
|
||||
for index, name in interfaces:
|
||||
# interface indices are non-zero integers
|
||||
self.assertGreater(index, 0)
|
||||
self.assertEqual(index, socket.if_nametoindex(name))
|
||||
self.assertEqual(name, socket.if_indextoname(index))
|
||||
|
||||
def testRefCountGetNameInfo(self):
|
||||
# Testing reference count for getnameinfo
|
||||
if hasattr(sys, "getrefcount"):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue