code: def test_copy_file_into_dshierarchy(srcdir=None, destdir=None):
      srcdir = Path(srcdir)
      src_ds = Dataset(srcdir).create(force=True)
      src_ds.save()
      # now build two nested datasets, such that lvl2 ends up in a subdataset
      dest_ds = Dataset(destdir).create()
      dest_ds.create(dest_ds.pathobj / "lvl2")
      assert_repo_status(dest_ds.path)
  
      dest_ds.copy_file(
          [src_ds.pathobj / "lvl1", dest_ds.pathobj], recursive=True
      )
      assert_repo_status(dest_ds.path)
  
      # we get the same structure as the input, just distributed across
      # nested datasets
      eq_(
          *[
              sorted(
                  r
                  for r in d.status(
                      result_xfm="relpaths", result_renderer="disabled"
                  )
                  # filter out subdataset entry in dest_ds
                  if r not in ("lvl2", ".gitmodules")
              )
              for d in (src_ds, dest_ds)
          ]
      )
  
file_path: datalad/datalad/local/tests/test_copy_file.py
imports: from os.path import join
  from datalad.api import copy_file
  from datalad.consts import DATALAD_SPECIAL_REMOTE
  from datalad.distribution.dataset import Dataset
  from datalad.tests.utils_pytest import assert_in_results, assert_raises, assert_repo_status, assert_status, chpwd, eq_, nok_, ok_, ok_file_has_content, serve_path_via_http, slow, with_tempfile, with_tree
  from datalad.utils import Path
label_desc: Use image node_id 6 for calling a global function with example usage: test_copy_file_into_dshierarchy(srcdir, destdir) without return types