Skip to content

Commit

Permalink
Work around tests using bad production code
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Arellano committed Mar 30, 2023
1 parent 928f739 commit 54f6ee8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
22 changes: 17 additions & 5 deletions test/python/visualization/test_circuit_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ def test_teleport(self):
circuit.x(qr[2]).c_if(cr, 2)
circuit.measure(qr[2], cr[2])

circuit_drawer(circuit, filename=filename, output="latex_source")
# TODO(#9880): This is a hack to work-around production code incorrectly using a
# deprecated property. Remove the assertWarns once fixed.
with self.assertWarns(DeprecationWarning):
circuit_drawer(circuit, filename=filename, output="latex_source")

self.assertEqualToReference(filename)

Expand Down Expand Up @@ -197,7 +200,10 @@ def test_conditional(self):
circuit.measure(qr, cr)
circuit.h(qr[0]).c_if(cr, 2)

circuit_drawer(circuit, filename=filename, output="latex_source")
# TODO(#9880): This is a hack to work-around production code incorrectly using a
# deprecated property. Remove the assertWarns once fixed.
with self.assertWarns(DeprecationWarning):
circuit_drawer(circuit, filename=filename, output="latex_source")

self.assertEqualToReference(filename)

Expand Down Expand Up @@ -557,7 +563,10 @@ def test_meas_condition(self):
circuit.h(qr[0])
circuit.measure(qr[0], cr[0])
circuit.h(qr[1]).c_if(cr, 1)
circuit_drawer(circuit, filename=filename, output="latex_source")
# TODO(#9880): This is a hack to work-around production code incorrectly using a
# deprecated property. Remove the assertWarns once fixed.
with self.assertWarns(DeprecationWarning):
circuit_drawer(circuit, filename=filename, output="latex_source")

self.assertEqualToReference(filename)

Expand Down Expand Up @@ -627,8 +636,11 @@ def test_measures_with_conditions(self):
circuit.measure(0, cr1[1])
circuit.measure(1, cr2[0]).c_if(cr1, 1)
circuit.h(0).c_if(cr2, 3)
circuit_drawer(circuit, cregbundle=False, filename=filename1, output="latex_source")
circuit_drawer(circuit, cregbundle=True, filename=filename2, output="latex_source")
# TODO(#9880): This is a hack to work-around production code incorrectly using a
# deprecated property. Remove the assertWarns once fixed.
with self.assertWarns(DeprecationWarning):
circuit_drawer(circuit, cregbundle=False, filename=filename1, output="latex_source")
circuit_drawer(circuit, cregbundle=True, filename=filename2, output="latex_source")
self.assertEqualToReference(filename1)
self.assertEqualToReference(filename2)

Expand Down
5 changes: 4 additions & 1 deletion test/python/visualization/timeline/test_layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ def test_qreg_creg_ascending(self):

def test_qreg_creg_descending(self):
"""Test qreg_creg_descending layout function."""
sorted_regs = layouts.qreg_creg_descending(self.regs)
# TODO(#9880): This is a hack to work-around production code incorrectly using a
# deprecated property. Remove the assertWarns once fixed.
with self.assertWarns(DeprecationWarning):
sorted_regs = layouts.qreg_creg_descending(self.regs)
ref_regs = [
self.regs[2],
self.regs[1],
Expand Down

0 comments on commit 54f6ee8

Please sign in to comment.