code: def test_use_store(unittest, test_data):
      class store_class(object):
          __name__ = "store_class"
  
          def __init__(self):
              self.data = dict()
  
          def keys(self):
              return self.data.keys()
  
          def items(self):
              return self.data.items()
  
      # First argument be a class
      with pytest.raises(BaseException) as error:
          global_state.use_store(None, None)
      assert "Must be a class" in str(error.value)
  
      # Store class must have the get, keys, items, clear, __setitem__, __delitem__, __contains__, __len__ attributes
      with pytest.raises(BaseException) as error:
          global_state.use_store(store_class, None)
      assert "Missing required methods" in str(error.value)
      setattr(store_class, "get", lambda self, k: self.data.get(k))
      setattr(store_class, "clear", lambda self: self.data.clear())
      setattr(
          store_class,
          "__setitem__",
          lambda self, k, v: self.data.update({k: v}),
      )
      setattr(
          store_class,
          "__delitem__",
          lambda self, k: self.data.pop(k, None),
      )
      setattr(
          store_class, "__contains__", lambda self, k: k in self.data
      )
      setattr(store_class, "__len__", lambda self: len(self.data))
  
      # Store class must have to_dict method if it's not a subclass of MutableMapping
      with pytest.raises(BaseException) as error:
          global_state.use_store(store_class, None)
      assert (
          'Must subclass MutableMapping or implement "to_dict"'
          in str(error.value)
      )
      setattr(store_class, "to_dict", lambda self: self.data)
  
      # Second argument must be a function
      with pytest.raises(BaseException) as error:
          global_state.use_store(store_class, None)
      assert "Must be a function" in str(error.value)
  
      # Function must take name as only parameter
      with pytest.raises(BaseException) as error:
          global_state.use_store(store_class, lambda: None)
      assert 'Must take "name" as the only parameter' in str(
          error.value
      )
  
      # So now we *should* have a good store class.
      # Verify that it converts from the default to this store correctly
      initialize_store(test_data)
      contents_before, type_before = (
          get_store_contents(),
          get_store_type(),
      )
  
      global_state.use_store(store_class, lambda name: store_class())
      contents_after = get_store_contents()
      type_after = get_store_type()
  
      unittest.assertEqual(contents_before, contents_after)
      unittest.assertNotEqual(type_before, type_after)
  
file_path: dtale/tests/dtale/test_global_state.py
imports: import mock
  import pandas
  import pytest
  import dtale.global_state
  from dtale.views import build_dtypes_state
label_desc: Use image node_id 10 for calling a global function with example usage: test_use_store(unittest, test_data) and returns: self, self