@@ -122,6 +122,20 @@ def test_simple_histogram(self):
122122 self .assertEqual ([HistogramMetricFamily ("a" , "help" , sum_value = 2 , buckets = [("1.0" , 0.0 ), ("+Inf" , 3.0 )])],
123123 list (families ))
124124
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+
125139 def test_negative_bucket_histogram (self ):
126140 families = text_string_to_metric_families ("""# TYPE a histogram
127141# HELP a help
@@ -731,9 +745,13 @@ def test_invalid_input(self):
731745 ('# TYPE a gaugehistogram\n a_gsum 1\n # EOF\n ' ),
732746 ('# TYPE a histogram\n a_count 1\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
733747 ('# 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 ' ),
734749 ('# 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 ' ),
735752 ('# TYPE a histogram\n a_bucket{le="1e-04"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
736753 ('# 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 ' ),
737755 ('# TYPE a histogram\n a_bucket{le="+INF"} 0\n # EOF\n ' ),
738756 ('# TYPE a histogram\n a_bucket{le="2"} 0\n a_bucket{le="1"} 0\n a_bucket{le="+Inf"} 0\n # EOF\n ' ),
739757 ('# 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):
754772 with self .assertRaises (ValueError , msg = case ):
755773 list (text_string_to_metric_families (case ))
756774
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-
767775
768776if __name__ == '__main__' :
769777 unittest .main ()
0 commit comments