class_docstr: Unit tests for the to_openqasm() method
class_docstr_tok: ["Unit","tests","for","the","to_openqasm","(",")","method"]
docstr: Test that observable rotations are correctly applied.
docstr_tok: ["Test","that","observable","rotations","are","correctly","applied","."]
code: def test_rotations(self):
      """Test that observable rotations are correctly applied."""
  
      with qml.queuing.AnnotatedQueue() as q_circuit:
          qml.Hadamard(wires=0)
          qml.CNOT(wires=[0, 1])
          qml.expval(qml.PauliX(0))
          qml.expval(qml.PauliZ(1))
          qml.expval(qml.Hadamard(2))
  
      circuit = qml.tape.QuantumScript.from_queue(q_circuit)
      res = circuit.to_openqasm()
  
      expected = dedent(
          """\
              OPENQASM 2.0;
              include "qelib1.inc";
              qreg q[3];
              creg c[3];
              h q[0];
              cx q[0],q[1];
              h q[0];
              ry(-0.7853981633974483) q[2];
              measure q[0] -> c[0];
              measure q[1] -> c[1];
              measure q[2] -> c[2];
              """
      )
  
      assert res == expected
  
      ops2 = circuit.operations + circuit.diagonalizing_gates
  
      with qml.queuing.AnnotatedQueue() as q2:
          _ = [o.queue() for o in ops2]
  
      circuit2 = qml.tape.QuantumScript.from_queue(q2)
      qasm2 = circuit2.to_openqasm()
  
      assert res == qasm2
  
imports: from textwrap import dedent
  import numpy
  import pytest
  import pennylane
  from pennylane.wires import Wires
label_desc: Use image node_id 9 for calling the TestToQasmUnitTests obj's underlying member method code with example usage: obj.test_rotations() without return types