Skip to content

Commit 95d36c0

Browse files
committed
Skip tests if aws credentials are missing
1 parent db8c4ad commit 95d36c0

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

tests/athena/test_athena.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,32 @@ def _terraform_config_valid() -> bool:
7070

7171
@pytest.fixture(scope="module")
7272
def aws_session():
73-
"""Create a boto3 session."""
73+
"""Create a boto3 session and verify credentials are available."""
7474
if not HAS_BOTO3:
7575
pytest.skip("boto3 not installed")
7676

7777
try:
78-
return boto3.Session(profile_name=AWS_PROFILE, region_name=AWS_REGION)
78+
session = boto3.Session(profile_name=AWS_PROFILE, region_name=AWS_REGION)
7979
except ProfileNotFound:
8080
# Fallback to default/env vars if profile doesn't exist
81-
return boto3.Session(region_name=AWS_REGION)
82-
except NoCredentialsError:
81+
try:
82+
session = boto3.Session(region_name=AWS_REGION)
83+
except (ProfileNotFound, NoCredentialsError):
84+
pytest.skip("AWS credentials not found. Skipping Athena integration tests.")
85+
86+
# Verify credentials are actually available by trying to get them
87+
# boto3.Session() doesn't throw if credentials are missing - it only fails on API calls
88+
try:
89+
credentials = session.get_credentials()
90+
if credentials is None:
91+
pytest.skip("AWS credentials not found. Skipping Athena integration tests.")
92+
# Force credential resolution to catch NoCredentialsError early
93+
credentials.get_frozen_credentials()
94+
except (NoCredentialsError, ProfileNotFound):
8395
pytest.skip("AWS credentials not found. Skipping Athena integration tests.")
8496

97+
return session
98+
8599

86100
@pytest.fixture(scope="module")
87101
def athena_setup(aws_session):

0 commit comments

Comments
 (0)