mirror of
https://github.com/python/cpython.git
synced 2025-08-28 20:56:54 +00:00
bpo-37007: Implement socket.if_nametoindex(), if_indextoname() and if_nameindex() on Windows (GH-13522)
This commit is contained in:
parent
fecb75c1bb
commit
8f96c9f8ed
6 changed files with 79 additions and 28 deletions
|
@ -973,16 +973,18 @@ class GeneralModuleTests(unittest.TestCase):
|
|||
self.assertIsInstance(_name, str)
|
||||
self.assertEqual(name, _name)
|
||||
|
||||
@unittest.skipUnless(hasattr(socket, 'if_nameindex'),
|
||||
'socket.if_nameindex() not available.')
|
||||
def testInvalidInterfaceNameIndex(self):
|
||||
# test nonexistent interface index/name
|
||||
@unittest.skipUnless(hasattr(socket, 'if_indextoname'),
|
||||
'socket.if_indextoname() not available.')
|
||||
def testInvalidInterfaceIndexToName(self):
|
||||
self.assertRaises(OSError, socket.if_indextoname, 0)
|
||||
self.assertRaises(OSError, socket.if_nametoindex, '_DEADBEEF')
|
||||
# test with invalid values
|
||||
self.assertRaises(TypeError, socket.if_nametoindex, 0)
|
||||
self.assertRaises(TypeError, socket.if_indextoname, '_DEADBEEF')
|
||||
|
||||
@unittest.skipUnless(hasattr(socket, 'if_nametoindex'),
|
||||
'socket.if_nametoindex() not available.')
|
||||
def testInvalidInterfaceNameToIndex(self):
|
||||
self.assertRaises(TypeError, socket.if_nametoindex, 0)
|
||||
self.assertRaises(OSError, socket.if_nametoindex, '_DEADBEEF')
|
||||
|
||||
@unittest.skipUnless(hasattr(sys, 'getrefcount'),
|
||||
'test needs sys.getrefcount()')
|
||||
def testRefCountGetNameInfo(self):
|
||||
|
@ -1638,9 +1640,7 @@ class GeneralModuleTests(unittest.TestCase):
|
|||
self.assertEqual(sockaddr, ('ff02::1de:c0:face:8d', 1234, 0, 0))
|
||||
|
||||
@unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.')
|
||||
@unittest.skipUnless(
|
||||
hasattr(socket, 'if_nameindex'),
|
||||
'if_nameindex is not supported')
|
||||
@unittest.skipIf(sys.platform == 'win32', 'does not work on Windows')
|
||||
@unittest.skipIf(AIX, 'Symbolic scope id does not work')
|
||||
def test_getaddrinfo_ipv6_scopeid_symbolic(self):
|
||||
# Just pick up any network interface (Linux, Mac OS X)
|
||||
|
@ -1672,9 +1672,7 @@ class GeneralModuleTests(unittest.TestCase):
|
|||
self.assertEqual(sockaddr, ('ff02::1de:c0:face:8d', 1234, 0, ifindex))
|
||||
|
||||
@unittest.skipUnless(support.IPV6_ENABLED, 'IPv6 required for this test.')
|
||||
@unittest.skipUnless(
|
||||
hasattr(socket, 'if_nameindex'),
|
||||
'if_nameindex is not supported')
|
||||
@unittest.skipIf(sys.platform == 'win32', 'does not work on Windows')
|
||||
@unittest.skipIf(AIX, 'Symbolic scope id does not work')
|
||||
def test_getnameinfo_ipv6_scopeid_symbolic(self):
|
||||
# Just pick up any network interface.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue