code: def test_ui_switcher():
      ui = _UI_Switcher("dialog")
      assert isinstance(ui.ui, DialogUI)
      message_str = str(ui.message)
      assert_equal(message_str, str(ui._ui.message))
  
      ui.set_backend("console")
      assert isinstance(ui.ui, ConsoleLog)
      assert_equal(str(ui.message), str(ui._ui.message))
      assert_not_equal(message_str, str(ui._ui.message))
      with assert_raises(AttributeError):
          ui.yesno
  
      ui.set_backend("annex")
  
      # Let's pretend we are under IPython
      class ZMQInteractiveShell(object):
          pass
  
      with patch(
          "datalad.utils.get_ipython",
          lambda: ZMQInteractiveShell(),
          create=True,
      ):
          ui = _UI_Switcher()
          assert isinstance(ui.ui, IPythonUI)
  
imports: from unittest.mock import patch
  from ...tests.utils_pytest import assert_equal, assert_false, assert_not_equal, assert_raises, with_testsui
  from ..None import _UI_Switcher
  from ..dialog import ConsoleLog, DialogUI, IPythonUI
label_desc: Use image node_id 1 for calling a global function with example usage: test_ui_switcher() without return types