code: def test_sidecar(path=None):
      ds = Dataset(path).create()
      # Simple sidecar message checks.
      ds.run("cd .> dummy0", message="sidecar arg", sidecar=True)
      assert_not_in('"cmd":', ds.repo.format_commit("%B"))
  
      ds.config.set(
          "datalad.run.record-sidecar", "false", scope="local"
      )
      ds.run("cd .> dummy1", message="sidecar config")
  
      assert_in('"cmd":', last_commit_msg(ds.repo))
  
      ds.config.set("datalad.run.record-sidecar", "true", scope="local")
      ds.run("cd .> dummy2", message="sidecar config")
      assert_not_in('"cmd":', last_commit_msg(ds.repo))
  
      # Don't break when config.get() returns multiple values. Here it's two
      # values in .gitconfig, but a more realistic scenario is a value in
      # $repo/.git/config that overrides a setting in ~/.config/git/config.
      ds.config.add(
          "datalad.run.record-sidecar", "false", scope="local"
      )
      ds.run("cd .> dummy3", message="sidecar config")
      assert_in('"cmd":', last_commit_msg(ds.repo))
  
      # make sure sidecar file is committed when explicitly specifying outputs
      ds.run(
          "cd .> dummy4",
          outputs=["dummy4"],
          sidecar=True,
          explicit=True,
          message="sidecar + specified outputs",
      )
      assert_not_in('"cmd":', last_commit_msg(ds.repo))
      assert_repo_status(ds.path)
  
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 5 for calling a global function with example usage: test_sidecar(path) without return types