code: def test_direct_cfg(path1=None, path2=None):
      # and if repo already exists and we have env var - we fail too
      # Adding backend so we get some commit into the repo
      ar = AnnexRepo(path1, create=True, backend="MD5E")
      del ar
      AnnexRepo._unique_instances.clear()  # fight flyweight
      for path in (path1, path2):
          with patch.dict(
              "os.environ", {"DATALAD_REPO_DIRECT": "True"}
          ):
              # try to create annex repo in direct mode as see how it fails
              with assert_raises(
                  DirectModeNoLongerSupportedError
              ) as cme:
                  AnnexRepo(path, create=True)
              assert_in(
                  "no longer supported by DataLad", str(cme.value)
              )  # we have generic part
              assert_in(
                  "datalad.repo.direct configuration", str(cme.value)
              )  # situation specific part
      # assert not op.exists(path2)   # that we didn't create it - we do!
      #   fixing for that would be too cumbersome since we first call GitRepo.__init__
      #   with create
      ar = AnnexRepo(path1)
      # check if we somehow didn't reset the flag
      assert not ar.is_direct_mode()
  
imports: from unittest.mock import patch
  from datalad.support import path
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import CommandNotAvailableError, DirectModeNoLongerSupportedError
  from datalad.tests.utils_pytest import SkipTest, assert_in, assert_raises, with_tempfile
label_desc: Use image node_id 2 for calling a global function with example usage: test_direct_cfg(path1, path2) without return types