code: def test_unlock_raises(path=None, path2=None, path3=None):
      # make sure, we are not within a dataset:
      _cwd = getpwd()
      chpwd(path)
  
      # no dataset and no path:
      assert_raises(
          InsufficientArgumentsError, unlock, dataset=None, path=None
      )
      # no dataset and path not within a dataset:
      assert_raises(NoDatasetFound, unlock, dataset=None, path=path2)
  
      create(path=path, annex=False)
      ds = Dataset(path)
      # no complaints
      ds.unlock()
  
      # make it annex, but call unlock with invalid path:
      (ds.pathobj / ".noannex").unlink()
      AnnexRepo(path, create=True)
  
      # One that doesn't exist.
      res = ds.unlock(
          path="notexistent.txt",
          result_xfm=None,
          on_failure="ignore",
          return_type="item-or-list",
      )
      eq_(res["message"], "path does not exist")
  
      # And one that isn't associated with a dataset.
      assert_in_results(
          ds.unlock(path=path2, on_failure="ignore"),
          status="error",
          message=(
              "path not underneath the reference dataset %s",
              ds.path,
          ),
      )
  
      chpwd(_cwd)
  
file_path: datalad/datalad/local/tests/test_unlock.py
imports: from datalad.api import clone, create, unlock
  from datalad.distribution.dataset import Dataset
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import InsufficientArgumentsError, NoDatasetFound
  from datalad.tests.utils_pytest import assert_cwd_unchanged, assert_false, assert_in_results, assert_not_in_results, assert_raises, assert_repo_status, assert_result_count, chpwd, eq_, getpwd, skip_if_root, slow, with_tempfile, with_tree
  from datalad.utils import Path
label_desc: Use image node_id 1 for calling a global function with example usage: test_unlock_raises(path, path2, path3) without return types