This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 5bbd70cb45 Import aiobotocore locally in tests rather than as global 
import (#40109)
5bbd70cb45 is described below

commit 5bbd70cb45504b9ec3a1d5d0febad6aae96fffc2
Author: Jarek Potiuk <[email protected]>
AuthorDate: Fri Jun 7 08:20:11 2024 +0200

    Import aiobotocore locally in tests rather than as global import (#40109)
    
    Importing aiobotocore globally causes test collection failure
    in case of tests that are run with latest botocore, becasuse
    the import is before "importorskip". Turning the imports to local
    ones fixes it.
---
 tests/providers/amazon/aws/hooks/test_base_aws.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/providers/amazon/aws/hooks/test_base_aws.py 
b/tests/providers/amazon/aws/hooks/test_base_aws.py
index 94629c2c07..984de7e223 100644
--- a/tests/providers/amazon/aws/hooks/test_base_aws.py
+++ b/tests/providers/amazon/aws/hooks/test_base_aws.py
@@ -28,7 +28,6 @@ from unittest import mock
 from unittest.mock import MagicMock, PropertyMock, mock_open
 from uuid import UUID
 
-import aiobotocore.session
 import boto3
 import botocore
 import jinja2
@@ -247,6 +246,8 @@ class TestSessionFactory:
 
         session_profile = async_session.get_config_variable("profile")
 
+        import aiobotocore.session
+
         assert session_profile == profile_name
         assert isinstance(async_session, aiobotocore.session.AioSession)
 
@@ -265,6 +266,8 @@ class TestSessionFactory:
         sf = BaseSessionFactory(conn=mock_conn_config, config=None)
         async_session = sf.create_session(deferrable=True)
         cred = await async_session.get_credentials()
+        import aiobotocore.session
+
         assert cred.access_key == "test_aws_access_key_id"
         assert cred.secret_key == "test_aws_secret_access_key"
         assert cred.token is None
@@ -338,9 +341,9 @@ class TestSessionFactory:
             # Validate method of botocore credentials provider.
             # It shouldn't be 'explicit' which refers in this case to initial 
credentials.
             credentials = await session.get_credentials()
+            import aiobotocore.session
 
             assert 
inspect.iscoroutinefunction(credentials.get_frozen_credentials)
-
             assert credentials.method == "sts-assume-role"
             assert isinstance(session, aiobotocore.session.AioSession)
 

Reply via email to