code: def test_py2_unicode_command(path=None):
      # Avoid OBSCURE_FILENAME to avoid windows-breakage (gh-2929).
      ds = Dataset(path).create()
      touch_cmd = "import sys; open(sys.argv[1], 'w').write('')"
      cmd_str = '{} -c "{}" {}'.format(
          sys.executable, touch_cmd, "bβ0.dat"
      )
      ds.run(cmd_str)
      assert_repo_status(ds.path)
      ok_exists(op.join(path, "bβ0.dat"))
  
      # somewhat desperate attempt to detect our own Github CI tests on a
      # crippled filesystem (VFAT) that is so crippled that it doesn't handle
      # what is needed here. It just goes mad with encoded bytestrings:
      # CommandError: ''python -c '"'"'import sys; open(sys.argv[1], '"'"'"'"'"'"'"'"'w'"'"'"'"'"'"'"'"').write('"'"'"'"'"'"'"'"''"'"'"'"'"'"'"'"')'"'"' '"'"' β1 '"'"''' failed with exitcode 1 under /crippledfs/
      if (
          not on_windows
          and os.environ.get("TMPDIR", None) != "/crippledfs"
      ):  # FIXME
          ds.run([sys.executable, "-c", touch_cmd, "bβ1.dat"])
          assert_repo_status(ds.path)
          ok_exists(op.join(path, "bβ1.dat"))
  
          # Send in a list of byte-strings to mimic a py2 command-line
          # invocation.
          ds.run(
              [
                  s.encode("utf-8")
                  for s in [sys.executable, "-c", touch_cmd, " β1 "]
              ]
          )
          assert_repo_status(ds.path)
          ok_exists(op.join(path, " β1 "))
  
      assert_in_results(
          ds.run("bβ2.dat", result_renderer=None, on_failure="ignore"),
          status="error",
          action="run",
      )
  
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 4 for calling a global function with example usage: test_py2_unicode_command(path) without return types