@@ -796,7 +796,19 @@ def test_restricted_registry(self):
796796
797797 m = Metric ('s' , 'help' , 'summary' )
798798 m .samples = [Sample ('s_sum' , {}, 7 )]
799- self .assertEqual ([m ], registry .restricted_registry (['s_sum' ]).collect ())
799+ self .assertEqual ([m ], list (registry .restricted_registry (['s_sum' ]).collect ()))
800+
801+ def test_restricted_registry_adds_new_metrics (self ):
802+ registry = CollectorRegistry ()
803+ Counter ('c_total' , 'help' , registry = registry )
804+
805+ restricted_registry = registry .restricted_registry (['s_sum' ])
806+
807+ Summary ('s' , 'help' , registry = registry ).observe (7 )
808+ m = Metric ('s' , 'help' , 'summary' )
809+ m .samples = [Sample ('s_sum' , {}, 7 )]
810+
811+ self .assertEqual ([m ], list (restricted_registry .collect ()))
800812
801813 def test_target_info_injected (self ):
802814 registry = CollectorRegistry (target_info = {'foo' : 'bar' })
@@ -820,11 +832,11 @@ def test_target_info_restricted_registry(self):
820832
821833 m = Metric ('s' , 'help' , 'summary' )
822834 m .samples = [Sample ('s_sum' , {}, 7 )]
823- self .assertEqual ([m ], registry .restricted_registry (['s_sum' ]).collect ())
835+ self .assertEqual ([m ], list ( registry .restricted_registry (['s_sum' ]).collect () ))
824836
825837 m = Metric ('target' , 'Target metadata' , 'info' )
826838 m .samples = [Sample ('target_info' , {'foo' : 'bar' }, 1 )]
827- self .assertEqual ([m ], registry .restricted_registry (['target_info' ]).collect ())
839+ self .assertEqual ([m ], list ( registry .restricted_registry (['target_info' ]).collect () ))
828840
829841
830842if __name__ == '__main__' :
0 commit comments