code: def test_has_stats(self):
      self.mock_stats = [
          CacheStat(
              category_name="st.singleton",
              cache_name="foo",
              byte_length=128,
          ),
          CacheStat(
              category_name="st.memo",
              cache_name="bar",
              byte_length=256,
          ),
      ]
  
      response = self.fetch("/_stcore/metrics")
      self.assertEqual(200, response.code)
      self.assertEqual(
          "application/openmetrics-text",
          response.headers.get("Content-Type"),
      )
  
      expected_body = (
          "# TYPE cache_memory_bytes gauge\n"
          "# UNIT cache_memory_bytes bytes\n"
          "# HELP Total memory consumed by a cache.\n"
          'cache_memory_bytes{cache_type="st.singleton",cache="foo"} 128\n'
          'cache_memory_bytes{cache_type="st.memo",cache="bar"} 256\n'
          "# EOF\n"
      ).encode("utf-8")
  
      self.assertEqual(expected_body, response.body)
  
file_path: streamlit/lib/tests/streamlit/web/server/stats_handler_test.py
imports: from unittest.mock import MagicMock
  import tornado.testing
  import tornado.web
  from google.protobuf.json_format import MessageToDict
  from tornado.httputil import HTTPHeaders
  from streamlit.proto.openmetrics_data_model_pb2 import MetricSet
  from streamlit.runtime.stats import CacheStat
  from streamlit.web.server.server import METRIC_ENDPOINT
  from streamlit.web.server.stats_request_handler import StatsRequestHandler
label_desc: Use image node_id 4 for calling the StatsHandlerTest obj's underlying member method code with example usage: obj.test_has_stats() without return types