From bf22c0f5e7a4e2c16e6c71cbd49ac72a1b0fb145 Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Thu, 11 Aug 2016 19:54:26 +0100 Subject: [PATCH] Skip tests that depend on the original C++ I have written a tonne of tests that compare against A&B's original C++. Until I can distribute the `anders_briegel` package which implements that original code, we now skip those tests if we see an ImportError. TODO: seems a little over-zealous right now ... --- tests/mock.py | 6 +++++- tests/test_against_anders_and_briegel.py | 1 - tests/test_clifford.py | 8 +++++++- tests/test_measurement.py | 1 - tests/test_qi.py | 4 ++-- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/mock.py b/tests/mock.py index a801c23..7e7d0c8 100644 --- a/tests/mock.py +++ b/tests/mock.py @@ -4,8 +4,12 @@ Mock graphs used for testing import numpy as np from abp import GraphState, clifford, qi -from anders_briegel import graphsim from numpy import random +import nose +try: + from anders_briegel import graphsim +except ImportError: + raise nose.SkipTest("Original C++ is not available, skipping test") # We always run with A&B's CZ table when we are testing clifford.use_old_cz() diff --git a/tests/test_against_anders_and_briegel.py b/tests/test_against_anders_and_briegel.py index 7a4746b..3c8dc1a 100644 --- a/tests/test_against_anders_and_briegel.py +++ b/tests/test_against_anders_and_briegel.py @@ -1,5 +1,4 @@ from abp import GraphState, CircuitModel, clifford -from anders_briegel import graphsim import numpy as np from numpy import random from tqdm import tqdm diff --git a/tests/test_clifford.py b/tests/test_clifford.py index 74a20ef..e373ac9 100644 --- a/tests/test_clifford.py +++ b/tests/test_clifford.py @@ -4,8 +4,8 @@ import itertools as it from abp import clifford from abp import build_tables from abp import qi +import nose from nose.tools import raises -from anders_briegel import graphsim def identify_pauli(m): @@ -79,6 +79,12 @@ def test_commuters(): def test_conjugation(): """ Test that clifford.conugate() agrees with graphsim.LocCliffOp.conjugate """ + try: + from anders_briegel import graphsim + except ImportError: + raise nose.SkipTest("Original C++ is not available, skipping test") + + for operation_index, transform_index in it.product(range(4), range(24)): transform = graphsim.LocCliffOp(transform_index) operation = graphsim.LocCliffOp(operation_index) diff --git a/tests/test_measurement.py b/tests/test_measurement.py index 0a71aac..d50ef65 100644 --- a/tests/test_measurement.py +++ b/tests/test_measurement.py @@ -1,7 +1,6 @@ import numpy as np from abp import GraphState from abp import qi, clifford -from anders_briegel import graphsim from tqdm import tqdm import random import itertools as it diff --git a/tests/test_qi.py b/tests/test_qi.py index 84dc909..575a75e 100644 --- a/tests/test_qi.py +++ b/tests/test_qi.py @@ -2,6 +2,7 @@ import numpy as np from abp import qi, GraphState from tqdm import tqdm import mock +import nose DEPTH = 1000 @@ -126,8 +127,7 @@ def test_against_chp(n=5): try: import chp except ImportError: - print "Not testing against CHP -- not installed" - return + raise nose.SkipTest("CHP is not installed") def get_chp_state(): """ Helper to convert CHP to CircuitModel """