code: def test_as_directory(checkpoint: Checkpoint):
      with checkpoint.as_directory() as checkpoint_path:
          checkpoint_path = Path(checkpoint_path)
          assert (checkpoint_path / _CHECKPOINT_CONTENT_FILE).exists()
  
          if isinstance(
              checkpoint.filesystem, pyarrow.fs.LocalFileSystem
          ):
              # We should have directly returned the local path
              assert str(checkpoint_path) == checkpoint.path
          else:
              # We should have downloaded to a temp dir.
              assert _CHECKPOINT_TEMP_DIR_PREFIX in checkpoint_path.name
  
      if isinstance(checkpoint.filesystem, pyarrow.fs.LocalFileSystem):
          # Checkpoint should not be deleted, if we directly gave the local path.
          assert (checkpoint_path / _CHECKPOINT_CONTENT_FILE).exists()
      else:
          # Should have been deleted, if the checkpoint downloaded to a temp dir.
          assert not checkpoint_path.exists()
  
file_path: ray/python/ray/train/tests/test_checkpoint.py
imports: import os
  from pathlib import Path
  import pyarrow.fs
  import pytest
  import ray
  from ray.train._checkpoint import _CHECKPOINT_TEMP_DIR_PREFIX, _METADATA_FILE_NAME, Checkpoint, _get_del_lock_path, _list_existing_del_locks
  from ray.train._internal.storage import _exists_at_fs_path, _upload_to_fs_path
  from ray.train.tests.test_new_persistence import _create_mock_custom_fs
label_desc: Use image node_id 5 for calling a global function with example usage: test_as_directory(checkpoint) without return types