From 36e5fa3bf75b57ea69905d4136b010408fd09bf5 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Fri, 14 Feb 2020 09:44:35 -0500 Subject: [PATCH 1/2] Skip TestJupyter tests if ibmq provider is not installed The tests in test.python.tools.jupyter.TestJupyter rely on the ibmq provider for the execution of the notebooks. However we don't require the local installation (or the configuration) of the provider for running tests anywhere else. In cases where someone is missing either ibmq or credentials the tests (of which only test_jupyter_jobs_pbars) in the class will fail because they can't import qiskit.IBMQ. This commit addresses this issue by adding a skip to the class on hasattr(qiskit, 'IBMQ') so that if the ibmq provider is not installed the tests will all skip. --- test/python/tools/jupyter/test_notebooks.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/python/tools/jupyter/test_notebooks.py b/test/python/tools/jupyter/test_notebooks.py index daae2a83bfe4..27d68cd2f5f8 100644 --- a/test/python/tools/jupyter/test_notebooks.py +++ b/test/python/tools/jupyter/test_notebooks.py @@ -20,6 +20,7 @@ import nbformat from nbconvert.preprocessors import ExecutePreprocessor +import qiskit from qiskit.tools.visualization import HAS_MATPLOTLIB from qiskit.test import (Path, QiskitTestCase, online_test, slow_test) @@ -30,6 +31,8 @@ JUPYTER_KERNEL = 'python3' +@unittest.skipUnless(hasattr(qiskit, 'IBMQ'), + 'qiskit-ibmq-provider is required for these tests') class TestJupyter(QiskitTestCase): """Notebooks test case.""" def setUp(self): From deba21303de41921f80b598e433947cda36956af Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Fri, 14 Feb 2020 10:27:35 -0500 Subject: [PATCH 2/2] Disable broken lint rule --- test/python/tools/jupyter/test_notebooks.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/python/tools/jupyter/test_notebooks.py b/test/python/tools/jupyter/test_notebooks.py index 27d68cd2f5f8..070e408c34b3 100644 --- a/test/python/tools/jupyter/test_notebooks.py +++ b/test/python/tools/jupyter/test_notebooks.py @@ -12,6 +12,8 @@ # copyright notice, and modified files need to carry a notice indicating # that they have been altered from the originals. +# pylint: disable=bad-docstring-quotes + """Tests for the wrapper functionality.""" import os