class_docstr: Tests for the state function
class_docstr_tok: ["Tests","for","the","state","function"]
docstr: Test if an error is raised for devices that are not capable of returning the state.
  This is tested by changing the capability of default.qubit
docstr_tok: ["Test","if","an","error","is","raised","for","devices","that","are","not","capable","of","returning","the","state",".","This","is","tested","by","changing","the","capability","of","default.qubit"]
code: def test_no_state_capability(self, monkeypatch):
      """Test if an error is raised for devices that are not capable of returning the state.
      This is tested by changing the capability of default.qubit"""
      dev = qml.device("default.qubit.legacy", wires=1)
      capabilities = dev.capabilities().copy()
      capabilities["returns_state"] = False
  
      @qml.qnode(dev)
      def func():
          return state()
  
      with monkeypatch.context() as m:
          m.setattr(
              DefaultQubitLegacy,
              "capabilities",
              lambda *args, **kwargs: capabilities,
          )
          with pytest.raises(
              qml.QuantumFunctionError,
              match="The current device is not capable",
          ):
              func()
  
imports: import numpy
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.devices import DefaultQubitLegacy
  from pennylane.measurements import State, Shots, density_matrix, expval, state
label_desc: Use image node_id 9 for calling the TestState obj's underlying member method code with example usage: obj.test_no_state_capability(monkeypatch) and returns: state