docstr: The gather_metrics decorator works as expected.
docstr_tok: ["The","gather_metrics","decorator","works","as","expected","."]
code: def test_gather_metrics_decorator(self):
      """The gather_metrics decorator works as expected."""
      ctx = get_script_run_ctx()
      assert ctx is not None
  
      @metrics_util.gather_metrics("test_function")
      def test_function(
          param1: int, param2: str, param3: float = 0.1
      ) -> str:
          st.markdown("This command should not be tracked")
          return "foo"
  
      test_function(param1=10, param2="foobar")
  
      self.assertEqual(len(ctx.tracked_commands), 1)
      self.assertTrue(
          ctx.tracked_commands[0].name.endswith("test_function")
      )
      self.assertTrue(
          ctx.tracked_commands[0].name.startswith("external:")
      )
  
      st.markdown("This function should be tracked")
  
      self.assertEqual(len(ctx.tracked_commands), 2)
      self.assertTrue(
          ctx.tracked_commands[0].name.endswith("test_function")
      )
      self.assertTrue(
          ctx.tracked_commands[0].name.startswith("external:")
      )
      self.assertEqual(ctx.tracked_commands[1].name, "markdown")
  
      ctx.reset()
      # Deactivate usage stats gathering
      ctx.gather_usage_stats = False
  
      self.assertEqual(len(ctx.tracked_commands), 0)
      test_function(param1=10, param2="foobar")
      self.assertEqual(len(ctx.tracked_commands), 0)
  
imports: import contextlib
  import datetime
  import unittest
  from collections import Counter
  from typing import Any, Callable
  from unittest.mock import MagicMock, mock_open, patch
  import pandas
  from parameterized import parameterized
  import streamlit
  import streamlit.components.v1
  from streamlit.connections import SnowparkConnection, SQLConnection
  from streamlit.runtime import metrics_util
  from streamlit.runtime.caching import cache_data_api, cache_resource_api
  from streamlit.runtime.legacy_caching import caching
  from streamlit.runtime.scriptrunner import get_script_run_ctx, magic_funcs
  from streamlit.web.server import websocket_headers
  from tests.delta_generator_test_case import DeltaGeneratorTestCase
label_desc: Use image node_id 5 for calling the PageTelemetryTest obj's underlying member method code with example usage: obj.test_gather_metrics_decorator() and returns: str