From 589110961a270733e4e3fb6add75117be124d984 Mon Sep 17 00:00:00 2001
From: Aarni Koskela <akx@iki.fi>
Date: Wed, 5 Mar 2025 14:02:19 +0200
Subject: [PATCH] Isolate redis-entraid dependency for tests (#3521)

Index: tests/test_credentials.py
--- tests/test_credentials.py.orig
+++ tests/test_credentials.py
@@ -16,7 +16,6 @@ from redis.credentials import CredentialProvider, User
 from redis.exceptions import ConnectionError, RedisError
 from redis.retry import Retry
 from redis.utils import str_if_bytes
-from redis_entraid.cred_provider import EntraIdCredentialsProvider
 from tests.conftest import (
     _get_client,
     get_credential_provider,
@@ -24,7 +23,12 @@ from tests.conftest import (
     skip_if_redis_enterprise,
 )
 
+try:
+    from redis_entraid.cred_provider import EntraIdCredentialsProvider
+except ImportError:
+    EntraIdCredentialsProvider = None
 
+
 @pytest.fixture()
 def endpoint(request):
     endpoint_name = request.config.getoption("--endpoint-name")
@@ -295,6 +299,7 @@ class TestUsernamePasswordCredentialProvider:
 
 
 @pytest.mark.onlynoncluster
+@pytest.mark.skipif(not EntraIdCredentialsProvider, reason="requires redis-entraid")
 class TestStreamingCredentialProvider:
     @pytest.mark.parametrize(
         "credential_provider",
@@ -567,6 +572,7 @@ class TestStreamingCredentialProvider:
 
 @pytest.mark.onlynoncluster
 @pytest.mark.cp_integration
+@pytest.mark.skipif(not EntraIdCredentialsProvider, reason="requires redis-entraid")
 class TestEntraIdCredentialsProvider:
     @pytest.mark.parametrize(
         "r_entra",
@@ -637,6 +643,7 @@ class TestEntraIdCredentialsProvider:
 
 @pytest.mark.onlycluster
 @pytest.mark.cp_integration
+@pytest.mark.skipif(not EntraIdCredentialsProvider, reason="requires redis-entraid")
 class TestClusterEntraIdCredentialsProvider:
     @pytest.mark.parametrize(
         "r_entra",
