summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2011-05-15 07:26:45 (GMT)
committerGregory P. Smith <greg@krypto.org>2011-05-15 07:26:45 (GMT)
commit5ed2e779f175dc648110a1d862e37d6e92bd2560 (patch)
treeaa19fa5461f195aac9c82fca74dba0190bf0909b /Lib
parent1a4de20d9505873beca1e20f948ae0abe875ebb1 (diff)
downloadcpython-5ed2e779f175dc648110a1d862e37d6e92bd2560.zip
cpython-5ed2e779f175dc648110a1d862e37d6e92bd2560.tar.gz
cpython-5ed2e779f175dc648110a1d862e37d6e92bd2560.tar.bz2
Issue #1746656: Add if_nameindex, if_nametoindex, if_indextoname
methods to the socket module.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_socket.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 2602b22..ffa2587 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -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"):