class_docstr: Tests for the expval function
class_docstr_tok: ["Tests","for","the","expval","function"]
docstr: Test that the return type of the observable is :attr:`ObservableReturnTypes.Expectation`
docstr_tok: ["Test","that","the","return","type","of","the","observable","is",":","attr",":","`","ObservableReturnTypes.Expectation","`"]
code: def test_observable_return_type_is_expectation(self, mocker):
      """Test that the return type of the observable is :attr:`ObservableReturnTypes.Expectation`"""
      dev = qml.device("default.qubit.legacy", wires=2)
  
      @qml.qnode(dev)
      def circuit():
          res = qml.expval(qml.PauliZ(0))
          assert res.return_type is Expectation
          return res
  
      new_dev = circuit.device
      spy = mocker.spy(qml.QubitDevice, "expval")
  
      circuit()
  
      custom_measurement_process(new_dev, spy)
  
file_path: pennylane/tests/measurements/legacy/test_expval_legacy.py
imports: import numpy
  import pytest
  import pennylane
  from pennylane.measurements import Expectation, Shots
  from pennylane.devices.qubit.measure import flatten_state
label_desc: Use image node_id 3 for calling the TestExpval obj's underlying member method code with example usage: obj.test_observable_return_type_is_expectation(mocker) and returns: res