Skip to content

Commit 43de060

Browse files
Fix optional dep error
1 parent aa4174e commit 43de060

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/csp_helpers.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
import os
66
from abc import ABC, abstractmethod
77
from time import time
8+
from typing import TYPE_CHECKING
89
from unittest import mock
910
from unittest.mock import patch
1011
from urllib.parse import parse_qs, urlparse
1112

1213
import jwt
13-
from botocore.awsrequest import AWSRequest
14-
from botocore.credentials import Credentials
14+
15+
from snowflake.connector.options import botocore, installed_boto
16+
17+
if TYPE_CHECKING:
18+
from botocore.awsrequest import AWSRequest
1519

1620
from snowflake.connector.vendored.requests.exceptions import ConnectTimeout, HTTPError
1721
from snowflake.connector.vendored.requests.models import Response
@@ -365,6 +369,8 @@ class FakeAwsEnvironment:
365369
"""
366370

367371
def __init__(self):
372+
assert installed_boto, "Cannot run test: botocore is not installed"
373+
368374
# Defaults used for generating a token. Can be overriden in individual tests.
369375
self.arn = "arn:aws:sts::123456789:assumed-role/My-Role/i-34afe100cad287fab"
370376
# Path of roles that can be assumed. Empty if no impersonation is allowed.
@@ -374,7 +380,9 @@ def __init__(self):
374380

375381
self.caller_identity = {"Arn": self.arn}
376382
self.region = "us-east-1"
377-
self.credentials = Credentials(access_key="ak", secret_key="sk")
383+
self.credentials = botocore.credentials.Credentials(
384+
access_key="ak", secret_key="sk"
385+
)
378386
self.instance_document = (
379387
b'{"region": "us-east-1", "instanceId": "i-1234567890abcdef0"}'
380388
)

0 commit comments

Comments
 (0)