code: def test_ignore_collecting_dvcignores(tmp_dir, dvc, dname):
      tmp_dir.gen({"dir": {"subdir": {}}})
  
      top_ignore_file = (tmp_dir / dname).with_name(
          DvcIgnore.DVCIGNORE_FILE
      )
      top_ignore_file.write_text(os.path.basename(dname))
      dvc._reset()
  
      ignore_file = tmp_dir / dname / DvcIgnore.DVCIGNORE_FILE
      ignore_file.write_text("foo")
  
      dvcignore = dvc.dvcignore
  
      top_ignore_path = os.path.dirname(os.fspath(top_ignore_file))
  
      sub_dir_path = os.path.dirname(os.fspath(ignore_file))
  
      assert (
          DvcIgnorePatterns(
              *merge_patterns(
                  os.path,
                  _to_pattern_info_list(
                      [".hg/", ".git/", ".git", ".dvc/"]
                  ),
                  os.fspath(tmp_dir),
                  _to_pattern_info_list([os.path.basename(dname)]),
                  top_ignore_path,
              ),
              os.sep,
          )
          == dvcignore._get_trie_pattern(top_ignore_path)
          == dvcignore._get_trie_pattern(sub_dir_path)
      )
  
imports: import os
  import shutil
  from pathlib import Path
  from typing import List
  import pytest
  from dvc.ignore import DvcIgnore, DvcIgnorePatterns
  from dvc.output import OutputIsIgnoredError
  from dvc.pathspec_math import PatternInfo, merge_patterns
  from dvc.repo import Repo
  from dvc.testing.tmp_dir import TmpDir
  from dvc_data.hashfile.build import IgnoreInCollectedDirError
  from dvc_data.hashfile.utils import get_mtime_and_size
label_desc: Use image node_id 9 for calling a global function with example usage: test_ignore_collecting_dvcignores(tmp_dir, dvc, dname) without return types