From d0604463f679475c231e87c0348941b262820ce9 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 23 Jun 2025 11:53:35 -0500 Subject: [PATCH] Remove tests which don't assert anything beyond what the util already does --- tests/metrics/test_metrics.py | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/tests/metrics/test_metrics.py b/tests/metrics/test_metrics.py index dd926692c4..4db878da72 100644 --- a/tests/metrics/test_metrics.py +++ b/tests/metrics/test_metrics.py @@ -26,9 +26,6 @@ from pkg_resources import parse_version from prometheus_client.core import Sample from synapse.metrics import REGISTRY, InFlightGauge, generate_latest -from synapse.metrics._twisted_exposition import ( - _set_prometheus_client_use_created_metrics, -) from synapse.util.caches.deferred_cache import DeferredCache from tests import unittest @@ -186,30 +183,3 @@ class CacheMetricsTests(unittest.HomeserverTestCase): self.assertEqual(items["synapse_util_caches_cache_size"], "1.0") self.assertEqual(items["synapse_util_caches_cache_max_size"], "777.0") - - -class PrometheusMetricsHackTestCase(unittest.HomeserverTestCase): - if parse_version(metadata.version("prometheus_client")) < parse_version("0.14.0"): - skip = "prometheus-client too old" - - def test_created_metrics_disabled(self) -> None: - """ - Tests that a brittle hack, to disable `_created` metrics, works. - This involves poking at the internals of prometheus-client. - It's not the end of the world if this doesn't work. - - This test gives us a way to notice if prometheus-client changes - their internals. - """ - import prometheus_client.metrics - - PRIVATE_FLAG_NAME = "_use_created" - - # By default, the pesky `_created` metrics are enabled. - # Check this assumption is still valid. - self.assertTrue(getattr(prometheus_client.metrics, PRIVATE_FLAG_NAME)) - - with patch("prometheus_client.metrics") as mock: - setattr(mock, PRIVATE_FLAG_NAME, True) - _set_prometheus_client_use_created_metrics(False) - self.assertFalse(getattr(mock, PRIVATE_FLAG_NAME, False))