From bfceefbb2614a54272dde43cc8e38a3a1fbc1965 Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Wed, 25 Feb 2026 17:30:59 -0800 Subject: [PATCH] parameterize test --- .../proxy/test_prometheus_cleanup.py | 42 +++++-------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/tests/test_litellm/proxy/test_prometheus_cleanup.py b/tests/test_litellm/proxy/test_prometheus_cleanup.py index bb03d270b76..fbdb7ef4ac3 100644 --- a/tests/test_litellm/proxy/test_prometheus_cleanup.py +++ b/tests/test_litellm/proxy/test_prometheus_cleanup.py @@ -249,48 +249,26 @@ class TestMaybeSetupPrometheusMultiprocDir: remaining = glob.glob(os.path.join(custom_dir, "*.db")) assert remaining == [] - def test_noop_for_single_worker(self): - """Single worker doesn't need multiproc dir.""" - litellm_settings = {"callbacks": ["prometheus"]} - + @pytest.mark.parametrize( + "num_workers, litellm_settings", + [ + (1, {"callbacks": ["prometheus"]}), + (4, {"callbacks": ["langfuse"]}), + (4, None), + ], + ) + def test_noop_when_setup_not_needed(self, num_workers, litellm_settings): with patch.dict(os.environ, {}, clear=False): os.environ.pop("PROMETHEUS_MULTIPROC_DIR", None) os.environ.pop("prometheus_multiproc_dir", None) ProxyInitializationHelpers._maybe_setup_prometheus_multiproc_dir( - num_workers=1, + num_workers=num_workers, litellm_settings=litellm_settings, ) assert os.environ.get("PROMETHEUS_MULTIPROC_DIR") is None - def test_noop_without_prometheus_callback(self): - """No prometheus callback = no setup needed.""" - litellm_settings = {"callbacks": ["langfuse"]} - - with patch.dict(os.environ, {}, clear=False): - os.environ.pop("PROMETHEUS_MULTIPROC_DIR", None) - os.environ.pop("prometheus_multiproc_dir", None) - - ProxyInitializationHelpers._maybe_setup_prometheus_multiproc_dir( - num_workers=4, - litellm_settings=litellm_settings, - ) - - assert os.environ.get("PROMETHEUS_MULTIPROC_DIR") is None - - def test_noop_with_none_litellm_settings(self): - """None litellm_settings = no setup needed.""" - with patch.dict(os.environ, {}, clear=False): - os.environ.pop("PROMETHEUS_MULTIPROC_DIR", None) - - ProxyInitializationHelpers._maybe_setup_prometheus_multiproc_dir( - num_workers=4, - litellm_settings=None, - ) - - assert os.environ.get("PROMETHEUS_MULTIPROC_DIR") is None - def test_prometheus_in_success_callback(self): """Prometheus in success_callback should also trigger setup.""" litellm_settings = {"success_callback": ["prometheus"]}