code: def test_cache_mixin_with_expand_user():
      # Test the memory cache is correctly created when using ~.
      cache_dir = "~/nilearn_data/test_cache"
      expand_cache_dir = os.path.expanduser(cache_dir)
      mixin_mock = CacheMixinTest(cache_dir)
  
      try:
          assert not os.path.exists(expand_cache_dir)
          mixin_mock.run()
          assert os.path.exists(expand_cache_dir)
      finally:
          if os.path.exists(expand_cache_dir):
              shutil.rmtree(expand_cache_dir)
  
file_path: nilearn/nilearn/_utils/tests/test_cache_mixin.py
imports: import os
  import shutil
  from pathlib import Path
  import pytest
  from joblib import Memory
  import nilearn
  from nilearn._utils import CacheMixin, cache_mixin
label_desc: Use image node_id 4 for calling a global function with example usage: test_cache_mixin_with_expand_user() without return types