code: def _test_annex_version_comparison(v, cmp_):
      class _runner(object):
          def run(self, cmd, *args, **kwargs):
              return dict(stdout=v, stderr="")
  
      ev = ExternalVersions()
      with set_annex_version(None), patch(
          "datalad.support.external_versions._runner", _runner()
      ), patch(
          "datalad.support.annexrepo.external_versions",
          ExternalVersions(),
      ):
          ev["cmd:annex"] < AnnexRepo.GIT_ANNEX_MIN_VERSION
          if cmp_ in (1, 0):
              AnnexRepo._check_git_annex_version()
              if cmp_ == 0:
                  assert_equal(AnnexRepo.git_annex_version, v)
          elif cmp == -1:
              with assert_raises(OutdatedExternalDependency):
                  ev.check(
                      "cmd:annex",
                      min_version=AnnexRepo.GIT_ANNEX_MIN_VERSION,
                  )
              with assert_raises(OutdatedExternalDependency):
                  AnnexRepo._check_git_annex_version()
  
imports: import logging
  import pytest
  from os import linesep
  from datalad import __version__
  from datalad.cmd import StdOutErrCapture, WitlessRunner
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import CommandError, MissingExternalDependency, OutdatedExternalDependency
  from datalad.tests.utils_pytest import SkipTest, assert_equal, assert_false, assert_greater, assert_greater_equal, assert_in, assert_not_in, assert_raises, assert_true, create_tree, patch, set_annex_version, swallow_logs, with_tempfile
  from ..external_versions import ExternalVersions, LooseVersion
label_desc: Use image node_id 10 for calling a global function with example usage: _test_annex_version_comparison(v, cmp_) and returns: dict