def test_get_network_interface_speed_not_permitted(self, mock_ioctl):
"""
In some cases (lucid seems to be affected), the ioctl() call is not
allowed for non-root users. In that case we intercept the error and
not report the network speed.
"""
sock = socket.socket(
socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_IP)
theerror = IOError()
theerror.errno = 1
theerror.message = "Operation not permitted"
# 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)
评论列表
文章目录