diff options
author | Gregory P. Smith <greg@krypto.org> | 2011-05-15 07:26:45 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2011-05-15 07:26:45 (GMT) |
commit | 5ed2e779f175dc648110a1d862e37d6e92bd2560 (patch) | |
tree | aa19fa5461f195aac9c82fca74dba0190bf0909b /Lib | |
parent | 1a4de20d9505873beca1e20f948ae0abe875ebb1 (diff) | |
download | cpython-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.py | 10 |
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"): |