diff --git a/test/terra/primitives/test_sampler_v2.py b/test/terra/primitives/test_sampler_v2.py index 0fe645e263..ecf9cc6048 100644 --- a/test/terra/primitives/test_sampler_v2.py +++ b/test/terra/primitives/test_sampler_v2.py @@ -513,6 +513,12 @@ def test_circuit_with_unitary(self): self.assertEqual(len(result), 1) self._assert_allclose(result[0].data.meas, np.array({1: self._shots})) + def get_data_bin_len(self, data): + if "keys" in dir(data): # qiskit 1.1 or later + return len(data.keys()) + else: + return len(astuple(data)) + def test_circuit_with_multiple_cregs(self): """Test for circuit with multiple classical registers.""" cases = [] @@ -581,7 +587,7 @@ def test_circuit_with_multiple_cregs(self): result = sampler.run([qc], shots=self._shots).result() self.assertEqual(len(result), 1) data = result[0].data - self.assertEqual(len(astuple(data)), 3) + self.assertEqual(self.get_data_bin_len(data), 3) for creg in qc.cregs: self.assertTrue(hasattr(data, creg.name)) self._assert_allclose(getattr(data, creg.name), np.array(target[creg.name])) @@ -614,7 +620,7 @@ def test_circuit_with_aliased_cregs(self): result = sampler.run([qc2], shots=self._shots).result() self.assertEqual(len(result), 1) data = result[0].data - self.assertEqual(len(astuple(data)), 3) + self.assertEqual(self.get_data_bin_len(data), 3) for creg_name in target: self.assertTrue(hasattr(data, creg_name)) self._assert_allclose(getattr(data, creg_name), np.array(target[creg_name])) diff --git a/test/terra/states/test_aer_statevector.py b/test/terra/states/test_aer_statevector.py index 0a78d681d5..0b11b1681d 100644 --- a/test/terra/states/test_aer_statevector.py +++ b/test/terra/states/test_aer_statevector.py @@ -153,12 +153,12 @@ def test_QFT(self): self.assertEqual(1, len(counts)) self.assertTrue("0000" in counts) - def test_single_qubit_QV(self): - """Test single qubit QuantumVolume""" - state = AerStatevector(QuantumVolume(1)) + def test_two_qubit_QV(self): + """Test two qubit QuantumVolume""" + state = AerStatevector(QuantumVolume(2)) counts = state.sample_counts(shots=1024) - self.assertEqual(1, len(counts)) - self.assertTrue("0" in counts) + self.assertEqual(4, len(counts)) + self.assertTrue("00" in counts) def test_evolve(self): """Test method and device properties"""