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 any direction other than 'left' or 'right' raises an error.
docstr_tok: ["Test","that","any","direction","other","than","'left","'","or","'right","'","raises","an","error","."]
code: def test_invalid_direction(self):
      """Test that any direction other than 'left' or 'right' raises an error."""
  
      def qfunc():
          qml.PauliX(wires=2)
          qml.CNOT(wires=[0, 2])
          qml.RX(0.2, wires=2)
  
      transformed_qfunc = commute_controlled(
          qfunc, direction="sideways"
      )
  
      with pytest.raises(ValueError, match="must be 'left' or 'right'"):
          qml.tape.make_qscript(transformed_qfunc)()
  
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 1 for calling the TestCommuteControlled obj's underlying member method code with example usage: obj.test_invalid_direction() without return types