class_docstr: Unit tests for helper functions in qml.devices.qubit.preprocess
class_docstr_tok: ["Unit","tests","for","helper","functions","in","qml.devices.qubit.preprocess"]
docstr: Test that expand_fn throws an error when an operation is does not define a matrix or decomposition.
docstr_tok: ["Test","that","expand_fn","throws","an","error","when","an","operation","is","does","not","define","a","matrix","or","decomposition","."]
code: def test_error_if_invalid_op(self):
      """Test that expand_fn throws an error when an operation is does not define a matrix or decomposition."""
  
      tape = QuantumScript(
          ops=[NoMatNoDecompOp(0)],
          measurements=[qml.expval(qml.Hadamard(0))],
      )
      with pytest.raises(DeviceError, match="not supported on abc"):
          decompose(tape, lambda op: op.has_matrix, name="abc")
  
imports: import pytest
  import pennylane
  from pennylane.operation import Operation
  from pennylane.tape import QuantumScript
  from pennylane import DeviceError
  from pennylane.devices.preprocess import no_sampling, validate_device_wires, validate_multiprocessing_workers, validate_adjoint_trainable_params, _operator_decomposition_gen, decompose, validate_observables, validate_measurements
label_desc: Use image node_id 1 for calling the TestDecomposeValidation obj's underlying member method code with example usage: obj.test_error_if_invalid_op() without return types