class_docstr: Unit tests for validate_and_expand_adjoint
class_docstr_tok: ["Unit","tests","for","validate_and_expand_adjoint"]
docstr: Test that the correct error is raised if a Hamiltonian measurement is differentiated
docstr_tok: ["Test","that","the","correct","error","is","raised","if","a","Hamiltonian","measurement","is","differentiated"]
code: def test_unsupported_obs(self):
      """Test that the correct error is raised if a Hamiltonian measurement is differentiated"""
      obs = qml.Hamiltonian([2, 0.5], [qml.PauliZ(0), qml.PauliY(1)])
      qs = qml.tape.QuantumScript(
          [qml.RX(0.5, wires=1)], [qml.expval(obs)]
      )
      qs.trainable_params = {0}
  
      program = qml.device("default.qubit").preprocess(
          ExecutionConfig(gradient_method="adjoint")
      )[0]
  
      with pytest.raises(qml.DeviceError, match=r"Observable "):
          program((qs,))
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane.devices import DefaultQubit, ExecutionConfig
  from pennylane.devices.default_qubit import stopping_condition
label_desc: Use image node_id 6 for calling the TestAdjointDiffTapeValidation obj's underlying member method code with example usage: obj.test_unsupported_obs() without return types