class_docstr: Tests for the validate observables transform.
class_docstr_tok: ["Tests","for","the","validate","observables","transform","."]
docstr: Test that expand_fn throws an error when an observable is invalid.
docstr_tok: ["Test","that","expand_fn","throws","an","error","when","an","observable","is","invalid","."]
code: def test_invalid_observable(self):
      """Test that expand_fn throws an error when an observable is invalid."""
      tape = QuantumScript(
          ops=[qml.PauliX(0)],
          measurements=[qml.expval(qml.GellMann(wires=0, index=1))],
      )
      with pytest.raises(DeviceError, match=r"not supported on abc"):
          validate_observables(
              tape, lambda obs: obs.name == "PauliX", 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 TestValidateObservables obj's underlying member method code with example usage: obj.test_invalid_observable() without return types