docstr: Scan the last_modified and last_accessed properties when scanning.
docstr_tok: ["Scan","the","last_modified","and","last_accessed","properties","when","scanning","."]
code: def test_scan_cache_last_modified_and_last_accessed(self) -> None:
      """Scan the last_modified and last_accessed properties when scanning."""
      TIME_GAP = 0.1
  
      # Make a first scan
      report_1 = scan_cache_dir(self.cache_dir)
  
      # Values from first report
      repo_1 = list(report_1.repos)[0]
      revision_1 = list(repo_1.revisions)[0]
      readme_file_1 = [
          file
          for file in revision_1.files
          if file.file_name == "README.md"
      ][0]
      another_file_1 = [
          file
          for file in revision_1.files
          if file.file_name == ".gitattributes"
      ][0]
  
      # Comparison of last_accessed/last_modified between file and repo
      self.assertLessEqual(
          readme_file_1.blob_last_accessed, repo_1.last_accessed
      )
      self.assertLessEqual(
          readme_file_1.blob_last_modified, repo_1.last_modified
      )
      self.assertEqual(revision_1.last_modified, repo_1.last_modified)
  
      # Sleep and write new readme
      time.sleep(TIME_GAP)
      readme_file_1.file_path.write_text("modified readme")
  
      # Sleep and read content from readme
      time.sleep(TIME_GAP)
      with readme_file_1.file_path.open("r") as f:
          _ = f.read()
  
      # Sleep and re-scan
      time.sleep(TIME_GAP)
      report_2 = scan_cache_dir(self.cache_dir)
  
      # Values from second report
      repo_2 = list(report_2.repos)[0]
      revision_2 = list(repo_2.revisions)[0]
      readme_file_2 = [
          file
          for file in revision_2.files
          if file.file_name == "README.md"
      ][0]
      another_file_2 = [
          file
          for file in revision_1.files
          if file.file_name == ".gitattributes"
      ][0]
  
      # Report 1 is not updated when cache changes
      self.assertLess(repo_1.last_accessed, repo_2.last_accessed)
      self.assertLess(repo_1.last_modified, repo_2.last_modified)
  
      # "Another_file.md" did not change
      self.assertEqual(another_file_1, another_file_2)
  
      # Readme.md has been modified and then accessed more recently
      self.assertGreaterEqual(
          readme_file_2.blob_last_modified
          - readme_file_1.blob_last_modified,
          TIME_GAP * 0.9,  # 0.9 factor because not exactly precise
      )
      self.assertGreaterEqual(
          readme_file_2.blob_last_accessed
          - readme_file_1.blob_last_accessed,
          2 * TIME_GAP * 0.9,  # 0.9 factor because not exactly precise
      )
      self.assertGreaterEqual(
          readme_file_2.blob_last_accessed
          - readme_file_2.blob_last_modified,
          TIME_GAP * 0.9,  # 0.9 factor because not exactly precise
      )
  
      # Comparison of last_accessed/last_modified between file and repo
      self.assertEqual(
          readme_file_2.blob_last_accessed, repo_2.last_accessed
      )
      self.assertEqual(
          readme_file_2.blob_last_modified, repo_2.last_modified
      )
      self.assertEqual(revision_2.last_modified, repo_2.last_modified)
  
imports: import os
  import tempfile
  import time
  import unittest
  from pathlib import Path
  from unittest.mock import Mock
  import pytest
  from huggingface_hub._snapshot_download import snapshot_download
  from huggingface_hub.commands.scan_cache import ScanCacheCommand
  from huggingface_hub.utils import DeleteCacheStrategy, HFCacheInfo, capture_output, scan_cache_dir
  from huggingface_hub.utils._cache_manager import CacheNotFound, _format_size, _format_timesince, _try_delete_path
  from .testing_constants import TOKEN
  from .testing_utils import rmtree_with_retry, with_production_testing, xfail_on_windows
label_desc: Use image node_id 8 for calling the TestCorruptedCacheUtils obj's underlying member method code with example usage: obj.test_scan_cache_last_modified_and_last_accessed() without return types