@@ -121,64 +121,6 @@ def test_metrics_exporter_interface():
121121 assert isinstance (exporter , MetricsExporter )
122122
123123
124- @pytest .mark .memory
125- def test_prometheus_exporter_with_prometheus_client_fallback ():
126- """Test PrometheusExporter with use_prometheus_client=True falls back gracefully."""
127-
128- # When prometheus_client is not available, it should fall back to text mode
129- @cachier (backend = "memory" , enable_metrics = True )
130- def test_func (x ):
131- return x * 2
132-
133- test_func .clear_cache ()
134-
135- # Create exporter with use_prometheus_client=True (will use text mode as fallback)
136- exporter = PrometheusExporter (port = 9095 , use_prometheus_client = True )
137- exporter .register_function (test_func )
138-
139- # Generate some metrics
140- test_func (5 )
141- test_func (5 )
142-
143- # Verify function is registered
144- assert test_func in exporter ._registered_functions .values ()
145-
146- # Verify text metrics can be generated (fallback mode)
147- metrics_text = exporter ._generate_text_metrics ()
148- assert "cachier_cache_hits_total" in metrics_text
149-
150- test_func .clear_cache ()
151-
152-
153- @pytest .mark .memory
154- def test_prometheus_exporter_collector_metrics ():
155- """Test that custom collector generates correct metrics."""
156- from cachier import cachier
157- from cachier .exporters import PrometheusExporter
158-
159- @cachier (backend = "memory" , enable_metrics = True )
160- def test_func (x ):
161- return x * 2
162-
163- test_func .clear_cache ()
164-
165- # Use text mode to verify metrics are accessible
166- exporter = PrometheusExporter (port = 9096 , use_prometheus_client = False )
167- exporter .register_function (test_func )
168-
169- # Generate metrics
170- test_func (5 )
171- test_func (5 ) # hit
172- test_func (10 ) # miss
173-
174- # Get stats to verify
175- stats = test_func .metrics .get_stats ()
176- assert stats .hits == 1
177- assert stats .misses == 2
178-
179- test_func .clear_cache ()
180-
181-
182124@pytest .mark .memory
183125def test_prometheus_exporter_double_instantiation ():
184126 """Test that two PrometheusExporter instances both work independently."""
0 commit comments