This is an automated email from the ASF dual-hosted git repository.

hcr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/mahout.git


The following commit(s) were added to refs/heads/main by this push:
     new aae66327b Improve test coverage for qiskit_backend.py to 99% (#1112)
aae66327b is described below

commit aae66327b48ffc91196cdd78056c1f38d7f3f55c
Author: Howardisme <[email protected]>
AuthorDate: Wed Mar 4 18:26:43 2026 +0800

    Improve test coverage for qiskit_backend.py to 99% (#1112)
    
    * test: add fallback test for qiskit custom simulator
    
    * test: add coverage for draw_circuit method across all backends
    
    * test: add coverage for apply_swap_gate function across all backends
---
 testing/qumat/test_create_circuit.py    | 30 ++++++++++++++++++++++++++++++
 testing/qumat/test_multi_qubit_gates.py | 16 ++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/testing/qumat/test_create_circuit.py 
b/testing/qumat/test_create_circuit.py
index dc48c20c7..1f8eaa82f 100644
--- a/testing/qumat/test_create_circuit.py
+++ b/testing/qumat/test_create_circuit.py
@@ -194,3 +194,33 @@ class TestBackendConfigValidation:
 
         with pytest.raises(KeyError, match="missing required 
key.*backend_options"):
             QuMat(config)
+
+    def test_qiskit_custom_simulator_fallback(self):
+        """Test that Qiskit backend accepts simulator types outside the legacy 
map."""
+        config = {
+            "backend_name": "qiskit",
+            "backend_options": {"simulator_type": "matrix_product_state"},
+        }
+
+        qumat = QuMat(config)
+
+        assert qumat.backend is not None
+        assert qumat.backend.options.method == "matrix_product_state"
+
+
[email protected]("backend_name", TESTING_BACKENDS)
+class TestCircuitDrawing:
+    """Test class for circuit drawing functionality."""
+
+    def test_draw_circuit_returns_output(self, backend_name):
+        """Test that draw_circuit runs successfully and returns an output."""
+        backend_config = get_backend_config(backend_name)
+        qumat = QuMat(backend_config)
+
+        qumat.create_empty_circuit(num_qubits=2)
+        qumat.apply_hadamard_gate(0)
+        qumat.apply_cnot_gate(0, 1)
+
+        drawing = qumat.draw_circuit()
+
+        assert drawing is not None
diff --git a/testing/qumat/test_multi_qubit_gates.py 
b/testing/qumat/test_multi_qubit_gates.py
index d78cebae0..78a2b4c69 100644
--- a/testing/qumat/test_multi_qubit_gates.py
+++ b/testing/qumat/test_multi_qubit_gates.py
@@ -490,3 +490,19 @@ class TestMultiQubitGatesEdgeCases:
                 assert abs(probabilities[i] - probabilities[j]) < 0.05, (
                     f"Backends have inconsistent CNOT results: {results_dict}"
                 )
+
+
[email protected]("backend_name", TESTING_BACKENDS)
+def test_apply_swap_gate(backend_name):
+    """Test that the SWAP gate applies correctly across backends."""
+    backend_config = get_backend_config(backend_name)
+    qumat = QuMat(backend_config)
+
+    qumat.create_empty_circuit(num_qubits=2)
+
+    qumat.apply_pauli_x_gate(0)
+
+    qumat.apply_swap_gate(0, 1)
+
+    results = qumat.execute_circuit()
+    assert results is not None

Reply via email to