class_docstr: Tests for single-qubit gates being pushed through controlled gates.
class_docstr_tok: ["Tests","for","single-qubit","gates","being","pushed","through","controlled","gates","."]
docstr: Test that X-basis gates before controlled-X-type gates on controls don't get pushed.
docstr_tok: ["Test","that","X-basis","gates","before","controlled-X-type","gates","on","controls","do","n't","get","pushed","."]
code: def test_dont_push_x_gates(self, direction):
      """Test that X-basis gates before controlled-X-type gates on controls don't get pushed."""
  
      def qfunc():
          qml.PauliX(wires="a")
          qml.CNOT(wires=["a", "c"])
          qml.RX(0.2, wires="a")
          qml.Toffoli(wires=["c", "a", "b"])
  
      transformed_qfunc = commute_controlled(qfunc, direction=direction)
  
      ops = qml.tape.make_qscript(transformed_qfunc)().operations
  
      names_expected = ["PauliX", "CNOT", "RX", "Toffoli"]
      wires_expected = [
          Wires("a"),
          Wires(["a", "c"]),
          Wires("a"),
          Wires(["c", "a", "b"]),
      ]
      compare_operation_lists(ops, names_expected, wires_expected)
  
imports: import pytest
  from utils import compare_operation_lists, check_matrix_equivalence
  import pennylane
  from pennylane import numpy
  from pennylane.wires import Wires
  from pennylane.transforms.optimization import commute_controlled
label_desc: Use image node_id 6 for calling the TestCommuteControlled obj's underlying member method code with example usage: obj.test_dont_push_x_gates(direction) without return types