code: def test_copy_file_errors(dspath1=None, dspath2=None, nondspath=None):
      ds1 = Dataset(dspath1)
      # nothing given
      assert_raises(ValueError, copy_file)
      # no target directory given
      assert_raises(ValueError, ds1.copy_file, "somefile")
      # using multiple sources and --specs-from
      assert_raises(
          ValueError, ds1.copy_file, ["1", "2", "3"], specs_from="-"
      )
      # trying to copy to a dir that is not in a dataset
      ds1.create()
      assert_status(
          "error",
          ds1.copy_file(
              "somepath", target_dir=nondspath, on_failure="ignore"
          ),
      )
      # copy into a dataset that is not in the reference dataset
      ds2 = Dataset(dspath2).create()
      assert_status(
          "error",
          ds1.copy_file(
              "somepath", target_dir=dspath2, on_failure="ignore"
          ),
      )
  
      # attempt to copy from a directory, but no recursion is enabled.
      # use no reference ds to exercise a different code path
      assert_status(
          "impossible",
          copy_file([nondspath, dspath1], on_failure="ignore"),
      )
  
      # attempt to copy a file that doesn't exist
      assert_status(
          "impossible",
          copy_file(["funky", dspath1], on_failure="ignore"),
      )
  
      # attempt to copy a file without a destination given
      assert_raises(ValueError, copy_file, "somepath")
      assert_status(
          "impossible",
          copy_file(specs_from=["somepath"], on_failure="ignore"),
      )
  
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 2 for calling a global function with example usage: test_copy_file_errors(dspath1, dspath2, nondspath) without return types