def test_get_network_interface_speed_not_supported(self, mock_ioctl):
"""
Some drivers do not report the needed interface speed. In this case
an C{IOError} with errno 95 is raised ("Operation not supported").
If such an error is rasied, report the speed as -1.
"""
sock = socket.socket(
socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_IP)
theerror = IOError()
theerror.errno = 95
theerror.message = "Operation not supported"
# ioctl always raises
mock_ioctl.side_effect = theerror
result = get_network_interface_speed(sock, b"eth0")
mock_ioctl.assert_called_with(ANY, ANY, ANY)
self.assertEqual((-1, False), result)
评论列表
文章目录