class_docstr: Tests for the var function
class_docstr_tok: ["Tests","for","the","var","function"]
docstr: Test that variances for mid-circuit measurement values
  are correct for a single measurement value.
docstr_tok: ["Test","that","variances","for","mid-circuit","measurement","values","are","correct","for","a","single","measurement","value","."]
code: def test_observable_is_measurement_value(
      self, shots, phi, mocker, tol, tol_stochastic, device_name
  ):  # pylint: disable=too-many-arguments
      """Test that variances for mid-circuit measurement values
      are correct for a single measurement value."""
      np.random.seed(42)
      dev = qml.device(device_name, wires=2, shots=shots)
  
      @qml.qnode(dev)
      def circuit(phi):
          qml.RX(phi, 0)
          m0 = qml.measure(0)
          return qml.var(m0)
  
      new_dev = circuit.device
      spy = mocker.spy(qml.QubitDevice, "var")
  
      res = circuit(phi)
  
      atol = tol if shots is None else tol_stochastic
      expected = np.sin(phi / 2) ** 2 - np.sin(phi / 2) ** 4
      assert np.allclose(np.array(res), expected, atol=atol, rtol=0)
  
      if device_name != "default.mixed":
          custom_measurement_process(new_dev, spy)
  
file_path: pennylane/tests/measurements/legacy/test_var_legacy.py
imports: import numpy
  import pytest
  import pennylane
  from pennylane.measurements import Variance, Shots
  from pennylane.devices.qubit.measure import flatten_state
label_desc: Use image node_id 4 for calling the TestVar obj's underlying member method code with example usage: obj.test_observable_is_measurement_value(shots, phi, mocker, tol, tol_stochastic, device_name) and returns: qml