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 a tensor includes invalid obserables
docstr_tok: ["Test","that","expand_fn","throws","an","error","when","a","tensor","includes","invalid","obserables"]
code: def test_invalid_tensor_observable(self):
      """Test that expand_fn throws an error when a tensor includes invalid obserables"""
      tape = QuantumScript(
          ops=[qml.PauliX(0), qml.PauliY(1)],
          measurements=[
              qml.expval(qml.PauliX(0) @ qml.GellMann(wires=1, index=2))
          ],
      )
      with pytest.raises(DeviceError, match="not supported on device"):
          validate_observables(tape, lambda obj: obj.name == "PauliX")
  
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 2 for calling the TestValidateObservables obj's underlying member method code with example usage: obj.test_invalid_tensor_observable() without return types