'Ensure that kah raises \'URLTimeoutError\' when timeouts occur and raises
\'ScanMustStopException\' when the timeout limit is reached.'

def test_timeout(self):

    kah = self.kahdler
    host = self.host
    conn = self.conn
    req = self.req
    req.get_host = MagicMock(side_effect=[host, host])
    kah._start_transaction = MagicMock(side_effect=socket.timeout())
    conn_mgr = Mock()
    conn_mgr.get_available_connection = MagicMock(return_value=conn)
    conn_mgr.remove_connection = MagicMock(return_value=None)
    kah._cm = conn_mgr
    self.assertRaises(URLTimeoutError, kah.do_open, req)
    self.assertRaises(URLTimeoutError, kah.do_open, req)
    self.assertEqual(len(conn_mgr.get_available_connection.call_args_list), 2)
    self.assertEqual(len(conn_mgr.remove_connection.call_args_list), 2)
