code: def test_duecredit(path=None):
      # Just to check that no obvious side-effects
      run = WitlessRunner(cwd=path).run
      cmd = [
          sys.executable,
          "-c",
          "from datalad.support.gitrepo import GitRepo; GitRepo(%r, create=True)"
          % path,
      ]
  
      env = os.environ.copy()
  
      # Test with duecredit not enabled for sure
      env.pop("DUECREDIT_ENABLE", None)
      # Alternative workaround for what to be fixed by
      # https://github.com/datalad/datalad/pull/3215
      # where underlying datalad process might issue a warning since our temp
      # cwd is not matching possibly present PWD env variable
      env.pop("PWD", None)
  
      out = run(cmd, env=env, protocol=StdOutErrCapture)
      outs = "".join(
          out.values()
      )  # Let's not depend on where duecredit decides to spit out
      # All quiet
      test_string = "Data management and distribution platform"
      assert_not_in(test_string, outs)
  
      # and now enable DUECREDIT - output could come to stderr
      env["DUECREDIT_ENABLE"] = "1"
      out = run(cmd, env=env, protocol=StdOutErrCapture)
      outs = "".join(out.values())
  
      if external_versions["duecredit"]:
          assert_in(test_string, outs)
      else:
          assert_not_in(test_string, outs)
  
imports: import logging
  import os
  import os.path
  import sys
  import pytest
  from datalad import get_encoding_info
  from datalad.cmd import StdOutCapture, StdOutErrCapture, WitlessRunner
  from datalad.support.exceptions import CommandError, FileNotInRepositoryError, InvalidGitRepositoryError, NoSuchPathError, PathKnownToRepositoryError
  from datalad.support.external_versions import external_versions
  from datalad.support.gitrepo import GitRepo, _normalize_path, normalize_paths, to_options
  from datalad.support.sshconnector import get_connection_hash
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, DEFAULT_REMOTE, SkipTest, assert_cwd_unchanged, assert_equal, assert_false, assert_in, assert_in_results, assert_is_instance, assert_not_equal, assert_not_in, assert_raises, assert_repo_status, assert_true, create_tree, eq_, get_most_obscure_supported_name, integration, neq_, ok_, skip_if_no_network, skip_if_on_windows, skip_nomultiplex_ssh, slow, swallow_logs, with_tempfile, with_tree, xfail_buggy_annex_info
  from datalad.utils import Path, chpwd, getpwd, on_windows, rmtree
label_desc: Use image node_id 44 for calling a global function with example usage: test_duecredit(path) without return types