@@ -321,6 +321,16 @@ def collect(self):
321321                return  [metric_family ]
322322        self .registry .register (CustomCollector ())
323323
324+     def  test_untyped (self ):
325+         self .custom_collector (UntypedMetricFamily ('u' , 'help' , value = 1 ))
326+         self .assertEqual (1 , self .registry .get_sample_value ('u' , {}))
327+ 
328+     def  test_untyped_labels (self ):
329+         cmf  =  UntypedMetricFamily ('u' , 'help' , labels = ['a' , 'c' ])
330+         cmf .add_metric (['b' , 'd' ], 2 )
331+         self .custom_collector (cmf )
332+         self .assertEqual (2 , self .registry .get_sample_value ('u' , {'a' : 'b' , 'c' : 'd' }))
333+ 
324334    def  test_counter (self ):
325335        self .custom_collector (CounterMetricFamily ('c' , 'help' , value = 1 ))
326336        self .assertEqual (1 , self .registry .get_sample_value ('c' , {}))
@@ -370,6 +380,9 @@ def test_histogram_labels(self):
370380        self .assertEqual (3 , self .registry .get_sample_value ('h_sum' , {'a' : 'b' }))
371381
372382    def  test_bad_constructors (self ):
383+         self .assertRaises (ValueError , UntypedMetricFamily , 'u' , 'help' , value = 1 , labels = [])
384+         self .assertRaises (ValueError , UntypedMetricFamily , 'u' , 'help' , value = 1 , labels = ['a' ])
385+ 
373386        self .assertRaises (ValueError , CounterMetricFamily , 'c' , 'help' , value = 1 , labels = [])
374387        self .assertRaises (ValueError , CounterMetricFamily , 'c' , 'help' , value = 1 , labels = ['a' ])
375388
@@ -390,6 +403,8 @@ def test_bad_constructors(self):
390403        self .assertRaises (KeyError , HistogramMetricFamily , 'h' , 'help' , buckets = {}, sum_value = 1 )
391404
392405    def  test_labelnames (self ):
406+         cmf  =  UntypedMetricFamily ('u' , 'help' , labels = iter (['a' ]))
407+         self .assertEqual (('a' ,), cmf ._labelnames )
393408        cmf  =  CounterMetricFamily ('c' , 'help' , labels = iter (['a' ]))
394409        self .assertEqual (('a' ,), cmf ._labelnames )
395410        gmf  =  GaugeMetricFamily ('g' , 'help' , labels = iter (['a' ]))
0 commit comments