From 9eff485d9823b892af3dc540b7c68ca4d7e6eeb4 Mon Sep 17 00:00:00 2001 From: "Davide Gessa (dakk)" Date: Sat, 30 Dec 2023 15:59:01 +0100 Subject: [PATCH] separate tests in directories --- test/algo/__init__.py | 0 test/{ => algo}/test_algo.py | 2 +- .../test_deutschjozsa.py} | 2 +- test/{test_algo_grover.py => algo/test_grover.py} | 2 +- test/{test_algo_simon.py => algo/test_simon.py} | 2 +- test/ast2logic/__init__.py | 0 .../test_translate_arg.py} | 0 .../test_translate_exp.py} | 0 .../test_translate_stmt.py} | 0 test/qlassf/__init__.py | 0 test/{test_qlassf_bool.py => qlassf/test_bool.py} | 2 +- test/{test_qlassf_builtin.py => qlassf/test_builtin.py} | 2 +- test/{test_qlassf_for_loop.py => qlassf/test_for_loop.py} | 2 +- .../test_functiondef.py} | 2 +- .../test_hybrid_quantum.py} | 6 +++--- .../test_ifthenelse.py} | 2 +- test/{test_qlassf_int.py => qlassf/test_int.py} | 2 +- test/{test_qlassf_list.py => qlassf/test_list.py} | 2 +- test/{test_qlassf_matrix.py => qlassf/test_matrix.py} | 2 +- test/{ => qlassf}/test_qlassf.py | 4 ++-- test/{test_qlassf_tuple.py => qlassf/test_tuple.py} | 2 +- test/test_decompiler.py | 2 +- 22 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 test/algo/__init__.py rename test/{ => algo}/test_algo.py (98%) rename test/{test_algo_deutschjozsa.py => algo/test_deutschjozsa.py} (97%) rename test/{test_algo_grover.py => algo/test_grover.py} (98%) rename test/{test_algo_simon.py => algo/test_simon.py} (95%) create mode 100644 test/ast2logic/__init__.py rename test/{test_ast2logic_t_arg.py => ast2logic/test_translate_arg.py} (100%) rename test/{test_ast2logic_t_exp.py => ast2logic/test_translate_exp.py} (100%) rename test/{test_ast2logic_t_stmt.py => ast2logic/test_translate_stmt.py} (100%) create mode 100644 test/qlassf/__init__.py rename test/{test_qlassf_bool.py => qlassf/test_bool.py} (98%) rename test/{test_qlassf_builtin.py => qlassf/test_builtin.py} (98%) rename test/{test_qlassf_for_loop.py => qlassf/test_for_loop.py} (97%) rename test/{test_qlassf_functiondef.py => qlassf/test_functiondef.py} (97%) rename test/{test_qlassf_hybrid_quantum.py => qlassf/test_hybrid_quantum.py} (92%) rename test/{test_qlassf_ifthenelse.py => qlassf/test_ifthenelse.py} (96%) rename test/{test_qlassf_int.py => qlassf/test_int.py} (99%) rename test/{test_qlassf_list.py => qlassf/test_list.py} (98%) rename test/{test_qlassf_matrix.py => qlassf/test_matrix.py} (98%) rename test/{ => qlassf}/test_qlassf.py (98%) rename test/{test_qlassf_tuple.py => qlassf/test_tuple.py} (98%) diff --git a/test/algo/__init__.py b/test/algo/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/test/test_algo.py b/test/algo/test_algo.py similarity index 98% rename from test/test_algo.py rename to test/algo/test_algo.py index e6b7863c..4b25ab40 100644 --- a/test/test_algo.py +++ b/test/algo/test_algo.py @@ -22,7 +22,7 @@ from qlasskit.algorithms import ConstantOracleException, QAlgorithm, oraclize from qlasskit.types import interpret_as_qtype -from .utils import ENABLED_COMPILERS +from ..utils import ENABLED_COMPILERS class QT(QAlgorithm): diff --git a/test/test_algo_deutschjozsa.py b/test/algo/test_deutschjozsa.py similarity index 97% rename from test/test_algo_deutschjozsa.py rename to test/algo/test_deutschjozsa.py index fc9a2fc0..7bafce4d 100644 --- a/test/test_algo_deutschjozsa.py +++ b/test/algo/test_deutschjozsa.py @@ -19,7 +19,7 @@ from qlasskit import qlassf from qlasskit.algorithms import DeutschJozsa -from .utils import ENABLED_COMPILERS, qiskit_measure_and_count +from ..utils import ENABLED_COMPILERS, qiskit_measure_and_count @parameterized_class(("compiler"), ENABLED_COMPILERS) diff --git a/test/test_algo_grover.py b/test/algo/test_grover.py similarity index 98% rename from test/test_algo_grover.py rename to test/algo/test_grover.py index ba9fad54..fd72db9e 100644 --- a/test/test_algo_grover.py +++ b/test/algo/test_grover.py @@ -17,7 +17,7 @@ from qlasskit import Qint2, qlassf from qlasskit.algorithms import Grover -from .utils import qiskit_measure_and_count +from ..utils import qiskit_measure_and_count class TestAlgoGrover(unittest.TestCase): diff --git a/test/test_algo_simon.py b/test/algo/test_simon.py similarity index 95% rename from test/test_algo_simon.py rename to test/algo/test_simon.py index eb3b94dd..290a58f5 100644 --- a/test/test_algo_simon.py +++ b/test/algo/test_simon.py @@ -19,7 +19,7 @@ from qlasskit import qlassf from qlasskit.algorithms import Simon -from .utils import ENABLED_COMPILERS, qiskit_measure_and_count +from ..utils import ENABLED_COMPILERS, qiskit_measure_and_count @parameterized_class(("compiler"), ENABLED_COMPILERS) diff --git a/test/ast2logic/__init__.py b/test/ast2logic/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/test/test_ast2logic_t_arg.py b/test/ast2logic/test_translate_arg.py similarity index 100% rename from test/test_ast2logic_t_arg.py rename to test/ast2logic/test_translate_arg.py diff --git a/test/test_ast2logic_t_exp.py b/test/ast2logic/test_translate_exp.py similarity index 100% rename from test/test_ast2logic_t_exp.py rename to test/ast2logic/test_translate_exp.py diff --git a/test/test_ast2logic_t_stmt.py b/test/ast2logic/test_translate_stmt.py similarity index 100% rename from test/test_ast2logic_t_stmt.py rename to test/ast2logic/test_translate_stmt.py diff --git a/test/qlassf/__init__.py b/test/qlassf/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/test/test_qlassf_bool.py b/test/qlassf/test_bool.py similarity index 98% rename from test/test_qlassf_bool.py rename to test/qlassf/test_bool.py index b0d623f8..563b7ce6 100644 --- a/test/test_qlassf_bool.py +++ b/test/qlassf/test_bool.py @@ -20,7 +20,7 @@ from qlasskit import exceptions, qlassf -from .utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results +from ..utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results a, b, c, d, e, g, h = symbols("a,b,c,d,e,g,h") _ret = Symbol("_ret") diff --git a/test/test_qlassf_builtin.py b/test/qlassf/test_builtin.py similarity index 98% rename from test/test_qlassf_builtin.py rename to test/qlassf/test_builtin.py index 086cef6f..01fbcae9 100644 --- a/test/test_qlassf_builtin.py +++ b/test/qlassf/test_builtin.py @@ -18,7 +18,7 @@ from qlasskit import qlassf -from .utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results +from ..utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results @parameterized_class(("compiler"), ENABLED_COMPILERS) diff --git a/test/test_qlassf_for_loop.py b/test/qlassf/test_for_loop.py similarity index 97% rename from test/test_qlassf_for_loop.py rename to test/qlassf/test_for_loop.py index 73fa59fd..2ff0eed8 100644 --- a/test/test_qlassf_for_loop.py +++ b/test/qlassf/test_for_loop.py @@ -19,7 +19,7 @@ from qlasskit import qlassf -from .utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results +from ..utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results a, b, c, d = symbols("a,b,c,d") _ret = Symbol("_ret") diff --git a/test/test_qlassf_functiondef.py b/test/qlassf/test_functiondef.py similarity index 97% rename from test/test_qlassf_functiondef.py rename to test/qlassf/test_functiondef.py index 7bd19890..c62e70c4 100644 --- a/test/test_qlassf_functiondef.py +++ b/test/qlassf/test_functiondef.py @@ -18,7 +18,7 @@ from qlasskit import qlassf -from .utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results +from ..utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results @parameterized_class(("compiler"), ENABLED_COMPILERS) diff --git a/test/test_qlassf_hybrid_quantum.py b/test/qlassf/test_hybrid_quantum.py similarity index 92% rename from test/test_qlassf_hybrid_quantum.py rename to test/qlassf/test_hybrid_quantum.py index 8487037e..fb0df652 100644 --- a/test/test_qlassf_hybrid_quantum.py +++ b/test/qlassf/test_hybrid_quantum.py @@ -16,7 +16,7 @@ from qlasskit import qlassf -from .utils import COMPILATION_ENABLED, qiskit_measure_and_count +from ..utils import COMPILATION_ENABLED, qiskit_measure_and_count class TestQlassfHybridQuantum(unittest.TestCase): @@ -26,8 +26,8 @@ def test_h(self): count = qiskit_measure_and_count(qf.circuit().export(), 128) [self.assertEqual(x in count, True) for x in ["0", "1"]] - # THIS IS NOT ALLOWED, since hybrid quantum is applicable only with gates that operates on 1 qubit - # a possible solution is to implement QFT directly as hybrid function. + # THIS IS NOT ALLOWED, since hybrid quantum is applicable only with gates that + # operates on 1 qubit a possible solution is to implement QFT directly as hybrid function. # def test_qft(self): # f = "def test(a: Qint2) -> Qint2:\n\treturn Q.QFT(a)" # qf = qlassf(f, to_compile=False, uncompute=False) diff --git a/test/test_qlassf_ifthenelse.py b/test/qlassf/test_ifthenelse.py similarity index 96% rename from test/test_qlassf_ifthenelse.py rename to test/qlassf/test_ifthenelse.py index 3ad4ae4f..b7a714a5 100644 --- a/test/test_qlassf_ifthenelse.py +++ b/test/qlassf/test_ifthenelse.py @@ -18,7 +18,7 @@ from qlasskit import exceptions, qlassf -from .utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results +from ..utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results @parameterized_class(("compiler"), ENABLED_COMPILERS) diff --git a/test/test_qlassf_int.py b/test/qlassf/test_int.py similarity index 99% rename from test/test_qlassf_int.py rename to test/qlassf/test_int.py index 7fed3714..6e13d90f 100644 --- a/test/test_qlassf_int.py +++ b/test/qlassf/test_int.py @@ -20,7 +20,7 @@ from qlasskit import Qint2, Qint4, exceptions, qlassf -from .utils import ( +from ..utils import ( COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results, diff --git a/test/test_qlassf_list.py b/test/qlassf/test_list.py similarity index 98% rename from test/test_qlassf_list.py rename to test/qlassf/test_list.py index 422ac569..7d7ec4cf 100644 --- a/test/test_qlassf_list.py +++ b/test/qlassf/test_list.py @@ -20,7 +20,7 @@ from qlasskit import qlassf -from .utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results +from ..utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results a, b, c, d = symbols("a,b,c,d") _ret = Symbol("_ret") diff --git a/test/test_qlassf_matrix.py b/test/qlassf/test_matrix.py similarity index 98% rename from test/test_qlassf_matrix.py rename to test/qlassf/test_matrix.py index 6a6f9a58..e7ed72ac 100644 --- a/test/test_qlassf_matrix.py +++ b/test/qlassf/test_matrix.py @@ -19,7 +19,7 @@ from qlasskit import qlassf -from .utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results +from ..utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results a, b, c, d = symbols("a,b,c,d") _ret = Symbol("_ret") diff --git a/test/test_qlassf.py b/test/qlassf/test_qlassf.py similarity index 98% rename from test/test_qlassf.py rename to test/qlassf/test_qlassf.py index 8d3618e4..5a58a86b 100644 --- a/test/test_qlassf.py +++ b/test/qlassf/test_qlassf.py @@ -19,8 +19,8 @@ from qlasskit import Qint2, Qint4, QlassF, exceptions, qlassf from qlasskit.boolopt.bool_optimizer import defaultOptimizerDebug -from . import utils -from .utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results +from .. import utils +from ..utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results class TestQlassfDecorator(unittest.TestCase): diff --git a/test/test_qlassf_tuple.py b/test/qlassf/test_tuple.py similarity index 98% rename from test/test_qlassf_tuple.py rename to test/qlassf/test_tuple.py index 783f0171..2438e71c 100644 --- a/test/test_qlassf_tuple.py +++ b/test/qlassf/test_tuple.py @@ -20,7 +20,7 @@ from qlasskit import qlassf -from .utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results +from ..utils import COMPILATION_ENABLED, ENABLED_COMPILERS, compute_and_compare_results a, b, c, d = symbols("a,b,c,d") _ret = Symbol("_ret") diff --git a/test/test_decompiler.py b/test/test_decompiler.py index 2cc7f972..5244f8af 100644 --- a/test/test_decompiler.py +++ b/test/test_decompiler.py @@ -24,7 +24,7 @@ from qlasskit.boolopt.bool_optimizer import custom_simplify_logic from qlasskit.decompiler import Decompiler -from .utils import ENABLED_COMPILERS, compute_and_compare_results +from .utils import ENABLED_COMPILERS def _merge_expressions(