From 3d4c3e35e65d050a060fff485c2a273fcb8472d5 Mon Sep 17 00:00:00 2001 From: Jahnvi Thakkar Date: Wed, 5 Aug 2026 21:35:00 +0530 Subject: [PATCH] FIX: make azure-core import optional in test_008_auth.py so collection works without azure --- tests/test_008_auth.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_008_auth.py b/tests/test_008_auth.py index 38994ad0..6fd2d657 100644 --- a/tests/test_008_auth.py +++ b/tests/test_008_auth.py @@ -29,7 +29,11 @@ _credential_cache_lock, _account_id_cache, ) -from azure.core.credentials import TokenCredential + +try: + from azure.core.credentials import TokenCredential +except ImportError: # pragma: no cover - azure-core is an optional test dependency + TokenCredential = None from mssql_python.constants import AuthType, ConstantsDDBC from mssql_python.exceptions import InterfaceError, OperationalError import secrets @@ -1920,6 +1924,7 @@ def test_empty_connection_string_with_token_provider(self, mock_ddbc_conn): class TestTokenProviderProtocol: """Tests for the runtime_checkable azure.core TokenCredential protocol.""" + @pytest.mark.skipif(TokenCredential is None, reason="azure-core not installed") def test_object_with_get_token_is_instance(self): """An object exposing get_token satisfies the Protocol at runtime.""" @@ -1929,6 +1934,7 @@ def get_token(self, *scopes, **kwargs): assert isinstance(Cred(), TokenCredential) + @pytest.mark.skipif(TokenCredential is None, reason="azure-core not installed") def test_object_without_get_token_is_not_instance(self): """An object missing get_token does not satisfy the Protocol."""