code: def test_unlock_cant_unlock(path=None):
      ds = Dataset(path).create(force=True)
      ds.save(path="regular_git", to_git=True)
      ds.save(path="already_unlocked")
      ds.unlock(path="already_unlocked")
      assert_repo_status(
          ds.path,
          # See managed branch note in previous test_unlock_directory.
          modified=[]
          if ds.repo.is_managed_branch()
          else ["already_unlocked"],
          untracked=["untracked"],
      )
      expected = {"regular_git": "notneeded", "untracked": "impossible"}
      # Don't add "already_unlocked" in v6+ because unlocked files are still
      # reported as having content and still passed to unlock. If we can
      # reliably distinguish v6+ unlocked files in status's output, we should
      # consider reporting a "notneeded" result.
      for f, status in expected.items():
          assert_in_results(
              ds.unlock(path=f, on_failure="ignore"),
              action="unlock",
              status=status,
              path=str(ds.pathobj / f),
          )
  
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 4 for calling a global function with example usage: test_unlock_cant_unlock(path) without return types