Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit c8434ce

Browse files
committed
Don't enforce the test for the hack on old prometheus-client versions before it was possible
1 parent 47d4b9e commit c8434ce

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/test_metrics.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15+
try:
16+
from importlib import metadata
17+
except ImportError:
18+
import importlib_metadata as metadata # type: ignore[no-redef]
1519
from unittest.mock import Mock, patch
1620

21+
from pkg_resources import parse_version
22+
1723
from synapse.app._base import _set_prometheus_client_use_created_metrics
1824
from synapse.metrics import REGISTRY, InFlightGauge, generate_latest
1925
from synapse.util.caches.deferred_cache import DeferredCache
@@ -167,6 +173,9 @@ def test_cache_metric(self):
167173

168174

169175
class PrometheusMetricsHackTestCase(unittest.HomeserverTestCase):
176+
if parse_version(metadata.version("prometheus_client")) < parse_version("0.14.0"):
177+
skip = "prometheus-client too old"
178+
170179
def test_created_metrics_disabled(self) -> None:
171180
"""
172181
Tests that a brittle hack, to disable `_created` metrics, works.

0 commit comments

Comments
 (0)