@@ -80,7 +80,13 @@ def s3_base() -> Generator[None, None, None]:
8080def get_boto3_client () -> botocore .client .BaseClient :
8181 # NB: we use the sync botocore client for setup
8282 session = botocore .session .Session ()
83- return session .create_client ("s3" , endpoint_url = endpoint_url )
83+
84+ # Prevent IllegalLocationConstraintException by explicitly setting region to
85+ # "us-east-1", which does not require configuring LocationConstraint during
86+ # bucket creation. (It is, in fact, forbidden for that region.) Necessary
87+ # in the face of "ambient" AWS configuration in a development environment
88+ # where the default region might be configured differently.
89+ return session .create_client ("s3" , endpoint_url = endpoint_url , region_name = "us-east-1" )
8490
8591
8692@pytest .fixture (autouse = True )
@@ -100,7 +106,14 @@ def s3(s3_base: None) -> Generator[s3fs.S3FileSystem, None, None]:
100106 client = get_boto3_client ()
101107 client .create_bucket (Bucket = test_bucket_name , ACL = "public-read" )
102108 s3fs .S3FileSystem .clear_instance_cache ()
103- s3 = s3fs .S3FileSystem (anon = False , client_kwargs = {"endpoint_url" : endpoint_url })
109+ s3 = s3fs .S3FileSystem (
110+ anon = False ,
111+ client_kwargs = {"endpoint_url" : endpoint_url },
112+ # Prevent "AssertionError: Session was never entered" from aiobotocore
113+ # at end of test execution. Using clear_instance_cache is insufficient,
114+ # although still necessary.
115+ skip_instance_cache = True ,
116+ )
104117 session = sync (s3 .set_session ())
105118 s3 .invalidate_cache ()
106119 yield s3
0 commit comments