@@ -122,6 +122,20 @@ def test_simple_histogram(self):
122
122
self .assertEqual ([HistogramMetricFamily ("a" , "help" , sum_value = 2 , buckets = [("1.0" , 0.0 ), ("+Inf" , 3.0 )])],
123
123
list (families ))
124
124
125
+ def test_histogram_noncanonical (self ):
126
+ families = text_string_to_metric_families ("""# TYPE a histogram
127
+ # HELP a help
128
+ a_bucket{le="0.00000000001"} 0
129
+ a_bucket{le="1.1e-4"} 0
130
+ a_bucket{le="1.1e-3"} 0
131
+ a_bucket{le="100000000000.0"} 0
132
+ a_bucket{le="+Inf"} 3
133
+ a_count 3
134
+ a_sum 2
135
+ # EOF
136
+ """ )
137
+ list (families )
138
+
125
139
def test_negative_bucket_histogram (self ):
126
140
families = text_string_to_metric_families ("""# TYPE a histogram
127
141
# HELP a help
@@ -731,9 +745,13 @@ def test_invalid_input(self):
731
745
('# TYPE a gaugehistogram\n a_gsum 1\n # EOF\n ' ),
732
746
('# TYPE a histogram\n a_count 1\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
733
747
('# TYPE a histogram\n a_bucket{le="+Inf"} 0\n a_count 1\n # EOF\n ' ),
748
+ ('# TYPE a histogram\n a_bucket{le="0"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
734
749
('# TYPE a histogram\n a_bucket{le="1"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
750
+ ('# TYPE a histogram\n a_bucket{le="0.0000000001"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
751
+ ('# TYPE a histogram\n a_bucket{le="1.1e-2"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
735
752
('# TYPE a histogram\n a_bucket{le="1e-04"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
736
753
('# TYPE a histogram\n a_bucket{le="1e+05"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
754
+ ('# TYPE a histogram\n a_bucket{le="10000000000"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
737
755
('# TYPE a histogram\n a_bucket{le="+INF"} 0\n # EOF\n ' ),
738
756
('# TYPE a histogram\n a_bucket{le="2"} 0\n a_bucket{le="1"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
739
757
('# TYPE a histogram\n a_bucket{le="1"} 1\n a_bucket{le="2"} 1\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
@@ -754,16 +772,6 @@ def test_invalid_input(self):
754
772
with self .assertRaises (ValueError , msg = case ):
755
773
list (text_string_to_metric_families (case ))
756
774
757
- @unittest .skipIf (sys .version_info < (2 , 7 ), "float repr changed from 2.6 to 2.7" )
758
- def test_invalid_float_input (self ):
759
- for case in [
760
- # Bad histograms.
761
- ('# TYPE a histogram\n a_bucket{le="9.999999999999999e+22"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
762
- ('# TYPE a histogram\n a_bucket{le="1.5555555555555201e+06"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
763
- ]:
764
- with self .assertRaises (ValueError ):
765
- list (text_string_to_metric_families (case ))
766
-
767
775
768
776
if __name__ == '__main__' :
769
777
unittest .main ()
0 commit comments