code: def test_getters(builtin_pkg):
      req = build_req_tuple(
          {
              "int": "1",
              "empty_int": "",
              "str": "hello",
              "empty_str": "",
              "bool": "true",
              "float": "1.1",
          }
      )
      val = utils.get_str_arg(req, "str")
      assert isinstance(val, str) and val == "hello"
      val = utils.get_str_arg(req, "str_def", default="def")
      assert val == "def"
      val = utils.get_str_arg(req, "empty_str")
      assert val is None
      with mock.patch(
          "{}.str".format(builtin_pkg), mock.Mock(side_effect=Exception)
      ):
          val = utils.get_str_arg(req, "str", default="def")
          assert val == "def"
      val = utils.get_int_arg(req, "int")
      assert isinstance(val, int) and val == 1
      val = utils.get_int_arg(req, "int_def", default=2)
      assert val == 2
      val = utils.get_int_arg(req, "empty_int")
      assert val is None
      with mock.patch(
          "{}.int".format(builtin_pkg), mock.Mock(side_effect=Exception)
      ):
          val = utils.get_int_arg(req, "int", default=2)
          assert val == 2
      val = utils.get_bool_arg(req, "bool")
      assert isinstance(val, bool) and val
  
      val = utils.get_float_arg(req, "float")
      assert isinstance(val, float) and val == 1.1
      val = utils.get_float_arg(req, "int_def", default=2.0)
      assert val == 2.0
      val = utils.get_float_arg(req, "empty_float")
      assert val is None
      with mock.patch(
          "{}.float".format(builtin_pkg),
          mock.Mock(side_effect=Exception),
      ):
          val = utils.get_float_arg(req, "float", default=2.0)
          assert val == 2
  
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 2 for calling a global function with example usage: test_getters(builtin_pkg) without return types