MCPcopy Index your code
hub / github.com/prometheus/client_python / test_commas

Method test_commas

tests/test_parser.py:192–213  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

190 self.assertEqualMetrics([metric_family], list(families))
191
192 def test_commas(self):
193 families = text_string_to_metric_families("""# TYPE a counter
194# HELP a help
195a{foo="bar",} 1
196a{foo="baz", } 1
197# TYPE b counter
198# HELP b help
199b{,} 2
200# TYPE c counter
201# HELP c help
202c{ ,} 3
203# TYPE d counter
204# HELP d help
205d{, } 4
206""")
207 a = CounterMetricFamily("a", "help", labels=["foo"])
208 a.add_metric(["bar"], 1)
209 a.add_metric(["baz"], 1)
210 b = CounterMetricFamily("b", "help", value=2)
211 c = CounterMetricFamily("c", "help", value=3)
212 d = CounterMetricFamily("d", "help", value=4)
213 self.assertEqualMetrics([a, b, c, d], list(families))
214
215 def test_multiple_trailing_commas(self):
216 text = """# TYPE a counter

Callers

nothing calls this directly

Calls 4

add_metricMethod · 0.95
assertEqualMetricsMethod · 0.95
CounterMetricFamilyClass · 0.90

Tested by

no test coverage detected