Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion tests/test_008_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""

Expand All @@ -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."""

Expand Down
Loading