@@ -51,7 +51,7 @@ def test_schedule_circuit_when_backend_tells_dt(self):
5151 backend = GenericBackendV2 (2 , seed = 42 )
5252
5353 sc = transpile (qc , backend , scheduling_method = "alap" , layout_method = "trivial" )
54- with self .assertRaises (DeprecationWarning ):
54+ with self .assertWarns (DeprecationWarning ):
5555 self .assertEqual (sc .duration , 451095 )
5656 self .assertEqual (sc .unit , "dt" )
5757 self .assertEqual (sc .data [0 ].operation .name , "delay" )
@@ -78,7 +78,7 @@ def test_schedule_circuit_when_transpile_option_tells_dt(self):
7878 seed_transpiler = 20 ,
7979 )
8080 target_durations = self .backend_with_dt .target .durations ()
81- with self .assertRaises (DeprecationWarning ):
81+ with self .assertWarns (DeprecationWarning ):
8282 self .assertAlmostEqual (sc .duration , (450450 + target_durations .get ("sx" , 0 )))
8383 self .assertEqual (sc .unit , "dt" )
8484 self .assertEqual (sc .data [0 ].operation .name , "delay" )
@@ -104,7 +104,7 @@ def test_schedule_circuit_in_sec_when_no_one_tells_dt(self):
104104 )
105105 target_durations = self .backend_with_dt .target .durations ()
106106
107- with self .assertRaises (DeprecationWarning ):
107+ with self .assertWarns (DeprecationWarning ):
108108 self .assertAlmostEqual (sc .duration , (450450 + target_durations .get ("sx" , 0 )) * self .dt )
109109 self .assertEqual (sc .unit , "s" )
110110 self .assertEqual (sc .data [0 ].operation .name , "delay" )
@@ -129,7 +129,7 @@ def test_transpile_single_delay_circuit(self):
129129 qc = QuantumCircuit (1 )
130130 qc .delay (1234 , 0 )
131131 sc = transpile (qc , backend = self .backend_with_dt , scheduling_method = "alap" )
132- with self .assertRaises (DeprecationWarning ):
132+ with self .assertWarns (DeprecationWarning ):
133133 self .assertEqual (sc .duration , 1234 )
134134 self .assertEqual (sc .data [0 ].operation .name , "delay" )
135135 self .assertEqual (sc .data [0 ].operation .duration , 1234 )
@@ -146,7 +146,7 @@ def test_transpile_t1_circuit(self):
146146 expected_scheduled = (
147147 target_durations .get ("x" , 1 ) + 4500 + target_durations .get ("measure" , 1 )
148148 )
149- with self .assertRaises (DeprecationWarning ):
149+ with self .assertWarns (DeprecationWarning ):
150150 self .assertEqual (scheduled .duration , expected_scheduled )
151151
152152 def test_transpile_delay_circuit_with_backend (self ):
@@ -158,7 +158,7 @@ def test_transpile_delay_circuit_with_backend(self):
158158 qc , backend = self .backend_with_dt , scheduling_method = "alap" , layout_method = "trivial"
159159 )
160160 target_durations = self .backend_with_dt .target .durations ()
161- with self .assertRaises (DeprecationWarning ):
161+ with self .assertWarns (DeprecationWarning ):
162162 self .assertEqual (scheduled .duration , target_durations .get ("cx" , (0 , 1 )) + 450 )
163163
164164 def test_transpile_circuit_with_custom_instruction (self ):
@@ -191,14 +191,14 @@ def test_transpile_circuit_with_custom_instruction(self):
191191 target = target ,
192192 dt = 1e-2 ,
193193 )
194- with self .assertRaises (DeprecationWarning ):
194+ with self .assertWarns (DeprecationWarning ):
195195 self .assertEqual (scheduled .duration , 1500 )
196196
197197 def test_transpile_delay_circuit_with_dt_but_without_scheduling_method (self ):
198198 qc = QuantumCircuit (1 )
199199 qc .delay (100 , 0 , unit = "ns" )
200200 transpiled = transpile (qc , backend = self .backend_with_dt )
201- with self .assertRaises (DeprecationWarning ):
201+ with self .assertWarns (DeprecationWarning ):
202202 self .assertEqual (transpiled .duration , None ) # not scheduled
203203 self .assertEqual (transpiled .data [0 ].operation .duration , 450 ) # unit is converted ns -> dt
204204
@@ -208,7 +208,7 @@ def test_transpile_delay_circuit_without_scheduling_method_or_durs(self):
208208 qc .delay (500 , 1 )
209209 qc .cx (0 , 1 )
210210 not_scheduled = transpile (qc )
211- with self .assertRaises (DeprecationWarning ):
211+ with self .assertWarns (DeprecationWarning ):
212212 self .assertEqual (not_scheduled .duration , None )
213213
214214 def test_raise_error_if_transpile_with_scheduling_method_but_without_durations (self ):
@@ -227,7 +227,7 @@ def test_invalidate_schedule_circuit_if_new_instruction_is_appended(self):
227227 scheduled = transpile (qc , backend = self .backend_with_dt , scheduling_method = "alap" )
228228 # append a gate to a scheduled circuit
229229 scheduled .h (0 )
230- with self .assertRaises (DeprecationWarning ):
230+ with self .assertWarns (DeprecationWarning ):
231231 self .assertEqual (scheduled .duration , None )
232232
233233 def test_unit_seconds_when_using_backend_durations (self ):
@@ -240,7 +240,7 @@ def test_unit_seconds_when_using_backend_durations(self):
240240 qc , backend = self .backend_with_dt , scheduling_method = "alap" , layout_method = "trivial"
241241 )
242242 target_durations = self .backend_with_dt .target .durations ()
243- with self .assertRaises (DeprecationWarning ):
243+ with self .assertWarns (DeprecationWarning ):
244244 self .assertEqual (scheduled .duration , target_durations .get ("cx" , (0 , 1 )) + 500 )
245245
246246 def test_per_qubit_durations (self ):
@@ -300,7 +300,7 @@ def test_convert_duration_to_dt(self):
300300 circ .measure_all ()
301301
302302 circuit_dt = transpile (circ , backend , scheduling_method = "asap" )
303- with self .assertRaises (DeprecationWarning ):
303+ with self .assertWarns (DeprecationWarning ):
304304 # reference duration and unit in dt
305305 ref_duration = circuit_dt .duration
306306 ref_unit = circuit_dt .unit
@@ -490,7 +490,7 @@ def test_change_dt_in_transpile(self):
490490 backend = GenericBackendV2 (1 , basis_gates = ["x" ], seed = 2 , dt = self .dt ),
491491 scheduling_method = "asap" ,
492492 )
493- with self .assertRaises (DeprecationWarning ):
493+ with self .assertWarns (DeprecationWarning ):
494494 org_duration = scheduled .duration
495495 # halve dt in sec = double duration in dt
496496 scheduled = transpile (
@@ -499,7 +499,7 @@ def test_change_dt_in_transpile(self):
499499 scheduling_method = "asap" ,
500500 dt = self .dt / 2 ,
501501 )
502- with self .assertRaises (DeprecationWarning ):
502+ with self .assertWarns (DeprecationWarning ):
503503 self .assertEqual (scheduled .duration , org_duration * 2 )
504504
505505 @data ("asap" , "alap" )
@@ -526,7 +526,7 @@ def test_can_transpile_circuits_after_assigning_parameters(self):
526526 qc .measure (0 , 0 )
527527 qc = qc .assign_parameters ({idle_dur : 0.1 })
528528 circ = transpile (qc , self .backend_with_dt )
529- with self .assertRaises (DeprecationWarning ):
529+ with self .assertWarns (DeprecationWarning ):
530530 self .assertEqual (circ .duration , None ) # not scheduled
531531 self .assertEqual (circ .data [1 ].operation .duration , 450 ) # converted in dt
532532
@@ -549,7 +549,7 @@ def test_can_transpile_circuits_with_unbounded_parameters(self):
549549 qc .measure (0 , 0 )
550550 # not assign parameter
551551 circ = transpile (qc , self .backend_with_dt )
552- with self .assertRaises (DeprecationWarning ):
552+ with self .assertWarns (DeprecationWarning ):
553553 self .assertEqual (circ .duration , None ) # not scheduled
554554 self .assertEqual (circ .data [1 ].operation .unit , "dt" ) # converted in dt
555555 self .assertEqual (
@@ -565,7 +565,7 @@ def test_can_schedule_circuits_with_bounded_parameters(self, scheduling_method):
565565 qc .measure (0 , 0 )
566566 qc = qc .assign_parameters ({idle_dur : 0.1 })
567567 circ = transpile (qc , self .backend_with_dt , scheduling_method = scheduling_method )
568- with self .assertRaises (DeprecationWarning ):
568+ with self .assertWarns (DeprecationWarning ):
569569 self .assertIsNotNone (circ .duration ) # scheduled
570570
571571 @data ("asap" , "alap" )
0 commit comments