diff --git a/tests/test_litellm/proxy/auth/test_auth_checks.py b/tests/test_litellm/proxy/auth/test_auth_checks.py index 174f424748f..3116e4ade96 100644 --- a/tests/test_litellm/proxy/auth/test_auth_checks.py +++ b/tests/test_litellm/proxy/auth/test_auth_checks.py @@ -44,6 +44,24 @@ def set_salt_key(monkeypatch): monkeypatch.setenv("LITELLM_SALT_KEY", "sk-1234") +@pytest.fixture(autouse=True) +def reset_constants_module(): + """Reset constants module to ensure clean state before each test""" + import importlib + from litellm import constants + from litellm.proxy.auth import auth_checks + + # Reload modules before test + importlib.reload(constants) + importlib.reload(auth_checks) + + yield + + # Reload modules after test to clean up + importlib.reload(constants) + importlib.reload(auth_checks) + + @pytest.fixture def valid_sso_user_defined_values(): return LiteLLM_UserTable( @@ -156,19 +174,13 @@ def test_get_cli_jwt_auth_token_default_expiration(valid_sso_user_defined_values def test_get_cli_jwt_auth_token_custom_expiration( - valid_sso_user_defined_values, monkeypatch, request + valid_sso_user_defined_values, monkeypatch ): """Test generating CLI JWT token with custom expiration via environment variable""" import importlib from litellm import constants from litellm.proxy.auth import auth_checks - # Register cleanup to reload modules after test (monkeypatch restores env var automatically) - def cleanup_modules(): - importlib.reload(constants) - importlib.reload(auth_checks) - request.addfinalizer(cleanup_modules) - # Set custom expiration to 48 hours monkeypatch.setenv("LITELLM_CLI_JWT_EXPIRATION_HOURS", "48")