class_docstr: Unit tests for validate_and_expand_adjoint
class_docstr_tok: ["Unit","tests","for","validate_and_expand_adjoint"]
docstr: Test if a QuantumFunctionError is raised for a tape with measurements that are not
  expectation values
docstr_tok: ["Test","if","a","QuantumFunctionError","is","raised","for","a","tape","with","measurements","that","are","not","expectation","values"]
code: def test_non_diagonal_non_expval(self):
      """Test if a QuantumFunctionError is raised for a tape with measurements that are not
      expectation values"""
  
      measurements = [qml.expval(qml.PauliZ(0)), qml.var(qml.PauliX(3))]
      qs = qml.tape.QuantumScript(ops=[], measurements=measurements)
  
      program = qml.device("default.qubit").preprocess(
          ExecutionConfig(gradient_method="adjoint")
      )[0]
  
      with pytest.raises(
          qml.DeviceError,
          match=r"adjoint diff supports either all expectation values or only measurements without observables",
      ):
          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 2 for calling the TestAdjointDiffTapeValidation obj's underlying member method code with example usage: obj.test_non_diagonal_non_expval() without return types