code: def test_color_enabled():
      # In the absence of NO_COLOR, follow ui.color, or ui.is_interactive if 'auto'
      with patch.dict(os.environ), patch(
          "datalad.support.ansi_colors.ui"
      ):
          os.environ.pop("NO_COLOR", None)
          for is_interactive in (True, False):
              colors.ui.is_interactive = is_interactive
              with patch_config({"datalad.ui.color": "off"}):
                  assert_equal(colors.color_enabled(), False)
              with patch_config({"datalad.ui.color": "on"}):
                  assert_equal(colors.color_enabled(), True)
              with patch_config({"datalad.ui.color": "auto"}):
                  assert_equal(colors.color_enabled(), is_interactive)
  
      # In the presence of NO_COLOR, default to disable, unless ui.color is "on"
      # The value of NO_COLOR should have no effect, so try true-ish and false-ish values
      for NO_COLOR in ("", "1", "0"):
          with patch.dict(os.environ, {"NO_COLOR": NO_COLOR}), patch(
              "datalad.support.ansi_colors.ui"
          ):
              for is_interactive in (True, False):
                  colors.ui.is_interactive = is_interactive
                  with patch_config({"datalad.ui.color": "on"}):
                      assert_equal(colors.color_enabled(), True)
                  for ui_color in ("off", "auto"):
                      with patch_config({"datalad.ui.color": ui_color}):
                          assert_equal(colors.color_enabled(), False)
  
imports: import os
  from unittest.mock import patch
  from datalad.support import ansi_colors
  from datalad.tests.utils_pytest import assert_equal, patch_config
label_desc: Use image node_id 1 for calling a global function with example usage: test_color_enabled() without return types