code: def test_modulepickling_simulate_deleted_cache(tmpdir):
      """
      Tests loading from a cache file after it is deleted.
      According to macOS `dev docs`__,
  
          Note that the system may delete the Caches/ directory to free up disk
          space, so your app must be able to re-create or download these files as
          needed.
  
      It is possible that other supported platforms treat cache files the same
      way.
  
      __ https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
      """  # noqa
      grammar = load_grammar()
      module = "fake parser"
  
      # Create the file
      path = Path(str(tmpdir.dirname), "some_path")
      with open(path, "w"):
          pass
      io = file_io.FileIO(path)
  
      try_to_save_module(grammar._hashed, io, module, lines=[])
      assert load_module(grammar._hashed, io) == module
  
      os.unlink(_get_hashed_path(grammar._hashed, path))
      parser_cache.clear()
  
      cached2 = load_module(grammar._hashed, io)
      assert cached2 is None
  
imports: import os
  import pytest
  import time
  from pathlib import Path
  from parso.cache import _CACHED_FILE_MAXIMUM_SURVIVAL, _VERSION_TAG, _get_cache_clear_lock_path, _get_hashed_path, _load_from_file_system, _NodeCacheItem, _remove_cache_and_update_lock, _save_to_file_system, load_module, parser_cache, try_to_save_module
  from parso._compatibility import is_pypy
  from parso import load_grammar
  from parso import cache
  from parso import file_io
  from parso import parse
label_desc: Use image node_id 4 for calling a global function with example usage: test_modulepickling_simulate_deleted_cache(tmpdir) without return types