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."""