code: def test_io_substitution(path=None):
      files = [OBSCURE_FILENAME + ".t", "normal.txt"]
      ds = Dataset(path).create(force=True)
      ds.save()
      # prefix the content of any given file with 'mod::'
      cmd = "import sys; from pathlib import Path; t = [(Path(p), 'mod::' + Path(p).read_text()) for p in sys.argv[1:]]; [k.write_text(v) for k, v in t]"
      cmd_str = '{} -c "{}" {{inputs}}'.format(sys.executable, cmd)
      # this should run and not crash with permission denied
      ds.run(
          cmd_str,
          inputs=["{outputs}"],
          outputs=["*.t*"],
          result_renderer="disabled",
      )
      # all filecontent got the prefix
      for f in files:
          ok_((ds.pathobj / f).read_text().startswith("mod::"))
  
      # we could just ds.rerun() now, and it should work, but this would make
      # rerun be a dependency of a core test
      # instead just double-run, but with a non-list input-spec.
      # should have same outcome
      ds.run(
          cmd_str,
          inputs="{outputs}",
          outputs="*.t*",
          result_renderer="disabled",
      )
      for f in files:
          ok_((ds.pathobj / f).read_text().startswith("mod::mod::"))
  
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 21 for calling a global function with example usage: test_io_substitution(path) without return types