Repository: Qiskit/qiskit

Issue:
Master is failing
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Informations
Due to a [recent change in the IBMQuantumExperience library](https://github.com/Qiskit/qiskit-api-py/commit/d1bd8b7870cd50e4e5167b515009d8a6047e620b), we are experiencing failing tests.

For a list of failing tests, see this Travis report:
https://travis-ci.org/Qiskit/qiskit-terra/jobs/415922713



Discussion:

Resolving patch:
diff --git a/qiskit/backends/ibmq/ibmqbackend.py b/qiskit/backends/ibmq/ibmqbackend.py
--- a/qiskit/backends/ibmq/ibmqbackend.py
+++ b/qiskit/backends/ibmq/ibmqbackend.py
@@ -11,6 +11,7 @@
 """
 import logging
 
+from IBMQuantumExperience import ApiError
 from qiskit import QISKitError
 from qiskit._util import _camel_case_to_snake_case, AvailableToOperationalDict
 from qiskit.backends import BaseBackend
@@ -237,9 +238,14 @@ def retrieve_job(self, job_id):
         Raises:
             IBMQBackendError: if retrieval failed
         """
-        job_info = self._api.get_job(job_id)
-        if 'error' in job_info:
-            raise IBMQBackendError('failed to get job id "{}"'.format(job_id))
+        try:
+            job_info = self._api.get_job(job_id)
+            if 'error' in job_info:
+                raise IBMQBackendError('Failed to get job "{}": {}'
+                                       .format(job_id, job_info['error']))
+        except ApiError as ex:
+            raise IBMQBackendError('Failed to get job "{}":{}'
+                                   .format(job_id, str(ex)))
         is_device = not bool(self._configuration.get('simulator'))
         job = IBMQJob(self._api, is_device,
                       job_id=job_info.get('id'),
diff --git a/qiskit/backends/ibmq/ibmqjob.py b/qiskit/backends/ibmq/ibmqjob.py
--- a/qiskit/backends/ibmq/ibmqjob.py
+++ b/qiskit/backends/ibmq/ibmqjob.py
@@ -184,12 +184,6 @@ def result(self, timeout=None, wait=5):
         self._wait_for_submission()
         try:
             this_result = self._wait_for_job(timeout=timeout, wait=wait)
-        except TimeoutError as err:
-            # A timeout error retrieving the results does not imply the job
-            # is failing. The job can be still running. This is why we are not
-            # throwing an exception here.
-            return Result({'id': self._id, 'status': 'ERROR',
-                           'result': str(err)})
         except ApiError as api_err:
             raise JobError(str(api_err))
 


Test patch:
diff --git a/test/python/test_ibmqjob_states.py b/test/python/test_ibmqjob_states.py
--- a/test/python/test_ibmqjob_states.py
+++ b/test/python/test_ibmqjob_states.py
@@ -221,12 +221,9 @@ def test_never_complete_result_with_timeout(self):
         job = self.run_with_api(NonQueuedAPI())
 
         self.wait_for_initialization(job)
-        # We never make the API status to progress so it is stuck on RUNNING
         with self.assertRaises(JobTimeoutError):
             job.result(timeout=0.2)
 
-        self.assertEqual(job.status(), JobStatus.RUNNING)
-
     def test_cancel_while_initializing_fails(self):
         job = self.run_with_api(CancellableAPI())
         can_cancel = job.cancel()
diff --git a/test/python/test_quantumprogram.py b/test/python/test_quantumprogram.py
--- a/test/python/test_quantumprogram.py
+++ b/test/python/test_quantumprogram.py
@@ -17,6 +17,7 @@
 
 from qiskit import (ClassicalRegister, QISKitError, QuantumCircuit,
                     QuantumRegister, QuantumProgram, Result)
+from qiskit.backends import JobTimeoutError
 from qiskit.qobj import Qobj
 from qiskit.tools import file_io
 from .common import requires_qe_access, QiskitTestCase, Path
@@ -1138,9 +1139,9 @@ def test_simulator_online_size(self, qe_token, qe_url):
         qc.measure(qr, cr)
         shots = 1
         q_program.set_api(qe_token, qe_url)
-        result = q_program.execute(['qc'], backend=backend_name, shots=shots,
-                                   max_credits=3, seed=73846087)
-        self.assertRaises(QISKitError, result.get_data, 'qc')
+        with self.assertRaises(JobTimeoutError):
+            q_program.execute(['qc'], backend=backend_name, shots=shots,
+                              max_credits=3, seed=73846087)
 
     @requires_qe_access
     def test_execute_several_circuits_simulator_online(self, qe_token, qe_url):