class_docstr: Test that the device declares its capabilities correctly.
class_docstr_tok: ["Test","that","the","device","declares","its","capabilities","correctly","."]
docstr: Tests that the device reports correctly whether it supports returning the state.
docstr_tok: ["Tests","that","the","device","reports","correctly","whether","it","supports","returning","the","state","."]
code: def test_returns_state(self, device_kwargs):
      """Tests that the device reports correctly whether it supports returning the state."""
      device_kwargs["wires"] = 1
      dev = qml.device(**device_kwargs)
      cap = dev.capabilities()
  
      @qml.qnode(dev)
      def circuit():
          qml.PauliX(wires=0)
          return qml.state()
  
      if not cap.get("returns_state"):
          # If the device is not defined to return state then the
          # access_state method should raise
          with pytest.raises(qml.QuantumFunctionError):
              dev.access_state()
  
          try:
              state = dev.state
          except (AttributeError, NotImplementedError):
              state = None
  
          assert state is None
      else:
          if dev.shots is not None:
              with pytest.warns(
                  UserWarning,
                  match="Requested state or density matrix with finite shots; the returned",
              ):
                  circuit()
          else:
              circuit()
  
          assert dev.state is not None
  
file_path: pennylane/pennylane/devices/tests/test_properties.py
imports: import pytest
  import pennylane.numpy
  import pennylane
  from pennylane._device import DeviceError
label_desc: Use image node_id 5 for calling the TestCapabilities obj's underlying member method code with example usage: obj.test_returns_state(device_kwargs) and returns: qml