Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import importlib.metadata
import importlib.util
import math
import unittest

import pytest

from prometheus_client.core import (
CollectorRegistry, CounterMetricFamily, GaugeMetricFamily,
HistogramMetricFamily, Metric, Sample, SummaryMetricFamily,
Expand Down Expand Up @@ -378,7 +381,20 @@ def collect(self):

HAS_BENCHMARK = importlib.util.find_spec("pytest_benchmark") is not None


def _benchmark_compatible_with_pytest():
# pytest-benchmark 5.3.0 and older read Node._nodeid, which pytest 9.2
# removed: https://github.com/ionelmc/pytest-benchmark/issues/321
from _pytest.nodes import Node
from packaging.version import Version
if hasattr(Node, '_nodeid'):
return True
return Version(importlib.metadata.version('pytest-benchmark')) > Version('5.3.0')


if HAS_BENCHMARK:
@pytest.mark.skipif(not _benchmark_compatible_with_pytest(),
reason='pytest-benchmark is not compatible with this pytest version')
def test_benchmark_text_string_to_metric_families(benchmark):
text = """# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# TYPE go_gc_duration_seconds summary
Expand Down
Loading