code: def test_get_host():
      with mock.patch(
          "socket.gethostname", mock.Mock(return_value="test")
      ), mock.patch(
          "socket.gethostbyname", mock.Mock(return_value="127.0.0.1")
      ):
          assert utils.get_host() == "test"
      with mock.patch(
          "socket.gethostbyname", mock.Mock(return_value="127.0.0.1")
      ):
          assert utils.get_host("test") == "test"
      with mock.patch(
          "socket.gethostname", mock.Mock(return_value="http://test")
      ), mock.patch(
          "socket.gethostbyname", mock.Mock(side_effect=Exception)
      ):
          assert utils.get_host() == "localhost"
      with mock.patch(
          "socket.gethostbyname", mock.Mock(side_effect=Exception)
      ):
          with pytest.raises(Exception) as error:
              utils.get_host("test")
          assert str(error.value).startswith(
              "Hostname (test) is not recognized"
          )
  
file_path: dtale/tests/dtale/test_utils.py
imports: from collections import namedtuple
  import mock
  import numpy
  import pandas
  import pytest
  from six import PY3
  import dtale.utils
  from tests import ExitStack
label_desc: Use image node_id 9 for calling a global function with example usage: test_get_host() without return types