44import unittest
55
66import pytest
7+ import pandas as pd
78
89from prometheus_client import (
910 CollectorRegistry , CONTENT_TYPE_LATEST , core , Counter , delete_from_gateway ,
1011 Enum , Gauge , generate_latest , Histogram , Info , instance_ip_grouping_key ,
11- Metric , push_to_gateway , pushadd_to_gateway , Summary , PandasGauge
12+ Metric , PandasGauge , push_to_gateway , pushadd_to_gateway , Summary
1213)
1314from prometheus_client .core import GaugeHistogramMetricFamily , Timestamp
1415from prometheus_client .exposition import (
1516 basic_auth_handler , default_handler , MetricsHandler ,
1617 passthrough_redirect_handler ,
1718)
1819
19- import pandas as pd
2020
2121class TestGenerateText (unittest .TestCase ):
2222 def setUp (self ):
@@ -204,8 +204,8 @@ def test_gauge_pandas(self):
204204 ou
205205 PandasGauge('report_pandas', 'metric description', df=df, columns=['columnn01', 'column02'], registry=self.registry)
206206 """
207- df = pd .DataFrame ({'a' : [1.1 ,2.2 ,3.3 ,4.4 ], 'b' :[5.1 ,6.2 ,7.3 ,8.4 ], 'value' : [1 ,2 , 3 , 4 ]})
208- df2 = pd .DataFrame ({'c' : [1.1 ,2.2 ,3.3 ,4.4 ], 'd' :[5.1 ,6.2 ,7.3 ,8.4 ], 'value' : [5 ,6 , 7 , 8 ]})
207+ df = pd .DataFrame ({'a' : [1.1 , 2.2 , 3.3 , 4.4 ], 'b' :[5.1 , 6.2 , 7.3 , 8.4 ], 'value' : [1 , 2 , 3 , 4 ]})
208+ df2 = pd .DataFrame ({'c' : [1.1 , 2.2 , 3.3 , 4.4 ], 'd' :[5.1 , 6.2 , 7.3 , 8.4 ], 'value' : [5 , 6 , 7 , 8 ]})
209209 PandasGauge ('report_pandas' , 'metric description' , df = df , columns = ['a' , 'b' , 'value' ], registry = self .registry )
210210 g2 = PandasGauge ('report_panda2s' , 'metric description2' , df = df2 , registry = self .registry )
211211
@@ -223,7 +223,7 @@ def test_gauge_pandas(self):
223223 b'report_panda2s(c=3.3 ,d=7.3 ) 7.0 \n '
224224 b'report_panda2s(c=4.4 ,d=8.4 ) 8.0 \n ' ,
225225 generate_latest (self .registry )
226- )
226+ )
227227
228228 g2 .set_metric (df2 )
229229 self .assertEqual (
@@ -240,7 +240,7 @@ def test_gauge_pandas(self):
240240 b'report_panda2s(c=3.3 ,d=7.3 ) 7 \n '
241241 b'report_panda2s(c=4.4 ,d=8.4 ) 8 \n ' ,
242242 generate_latest (self .registry )
243- )
243+ )
244244
245245 def test_gauge_pandas_columns (self ):
246246 """
@@ -253,8 +253,8 @@ def test_gauge_pandas_columns(self):
253253 ou
254254 PandasGauge('report_pandas', 'metric description', df=df, columns=['columnn01', 'column02'], registry=self.registry)
255255 """
256- df = pd .DataFrame ({'a' : [1.1 ,2.2 ,3.3 ,4.4 ], 'b' :[5.1 ,6.2 ,7.3 ,8.4 ], 'value' : [1 ,2 , 3 , 4 ]})
257- df2 = pd .DataFrame ({'c' : [1.1 ,2.2 ,3.3 ,4.4 ], 'd' :[5.1 ,6.2 ,7.3 ,8.4 ], 'result' : [5 ,6 , 7 , 8 ]})
256+ df = pd .DataFrame ({'a' : [1.1 , 2.2 , 3.3 , 4.4 ], 'b' :[5.1 , 6.2 , 7.3 , 8.4 ], 'value' : [1 , 2 , 3 , 4 ]})
257+ df2 = pd .DataFrame ({'c' : [1.1 , 2.2 , 3.3 , 4.4 ], 'd' :[5.1 , 6.2 , 7.3 , 8.4 ], 'result' : [5 , 6 , 7 , 8 ]})
258258 PandasGauge ('report_pandas' , 'metric description' , df = df , columns = ['a' , 'value' ], registry = self .registry )
259259 g2 = PandasGauge ('report_panda2s' , 'metric description2' , df = df2 , columns = ['d' , 'result' ],value = 'result' ,registry = self .registry )
260260
@@ -272,7 +272,7 @@ def test_gauge_pandas_columns(self):
272272 b'report_panda2s(d=7.3 ) 7.0 \n '
273273 b'report_panda2s(d=8.4 ) 8.0 \n ' ,
274274 generate_latest (self .registry )
275- )
275+ )
276276
277277class TestPushGateway (unittest .TestCase ):
278278 def setUp (self ):
0 commit comments