code: def test_run_assume_ready(path=None):
      ds = Dataset(path).create()
      repo = ds.repo
      adjusted = repo.is_managed_branch()
  
      # --assume-ready=inputs
  
      (repo.pathobj / "f1").write_text("f1")
      ds.save()
  
      def cat_cmd(fname):
          return [
              sys.executable,
              "-c",
              "import sys; print(open(sys.argv[-1]).read())",
              fname,
          ]
  
      assert_in_results(
          ds.run(cat_cmd("f1"), inputs=["f1"]),
          action="get",
          type="file",
      )
      # Same thing, but without the get() call.
      assert_not_in_results(
          ds.run(cat_cmd("f1"), inputs=["f1"], assume_ready="inputs"),
          action="get",
          type="file",
      )
  
      ds.drop("f1", reckless="kill")
      if not adjusted:
          # If the input is not actually ready, the command will fail.
          assert_in_results(
              ds.run(
                  cat_cmd("f1"),
                  inputs=["f1"],
                  assume_ready="inputs",
                  on_failure="ignore",
                  result_renderer=None,
              ),
              action="run",
              status="error",
          )
  
      # --assume-ready=outputs
  
      def unlink_and_write_cmd(fname):
          # This command doesn't care whether the output file is unlocked because
          # it removes it ahead of time anyway.
          return [
              sys.executable,
              "-c",
              "import sys; import os; import os.path as op; "
              "f = sys.argv[-1]; op.lexists(f) and os.unlink(f); "
              "open(f, mode='w').write(str(sys.argv))",
              fname,
          ]
  
      (repo.pathobj / "f2").write_text("f2")
      ds.save()
  
      res = ds.run(unlink_and_write_cmd("f2"), outputs=["f2"])
      if not adjusted:
          assert_in_results(res, action="unlock", type="file")
      # Same thing, but without the unlock() call.
      res = ds.run(
          unlink_and_write_cmd("f2"),
          outputs=["f2"],
          assume_ready="outputs",
      )
      assert_not_in_results(res, action="unlock", type="file")
  
      # --assume-ready=both
  
      res = ds.run(
          unlink_and_write_cmd("f2"), outputs=["f2"], inputs=["f2"]
      )
      assert_in_results(res, action="get", type="file")
      if not adjusted:
          assert_in_results(res, action="unlock", type="file")
  
      res = ds.run(
          unlink_and_write_cmd("f2"),
          outputs=["f2"],
          inputs=["f2"],
          assume_ready="both",
      )
      assert_not_in_results(res, action="get", type="file")
      assert_not_in_results(res, action="unlock", type="file")
  
imports: import logging
  import os
  import os.path
  import sys
  from os import mkdir, remove
  from unittest.mock import patch
  from datalad.api import clone, run
  from datalad.cli.main import main
  from datalad.core.local.run import _format_iospecs, _get_substitutions, format_command, run_command
  from datalad.distribution.dataset import Dataset
  from datalad.support.exceptions import CommandError, IncompleteResultsError, NoDatasetFound
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, OBSCURE_FILENAME, assert_false, assert_in, assert_in_results, assert_not_in, assert_not_in_results, assert_raises, assert_repo_status, assert_result_count, assert_status, create_tree, eq_, known_failure_windows, neq_, ok_, ok_exists, ok_file_has_content, patch_config, swallow_logs, swallow_outputs, with_tempfile, with_tree
  from datalad.utils import chpwd, ensure_unicode, on_windows
label_desc: Use image node_id 9 for calling a global function with example usage: test_run_assume_ready(path) and returns: list, list