Skip to content

Unable to create zarr store in unit test using moto #3651

@christine-e-smit

Description

@christine-e-smit

Zarr version

2.18.7

Numcodecs version

0.15.1

Python Version

3.14.2

Operating System

Mac

Installation

using conda

Description

I'm trying to update a bunch of older unit tests to use moto>5. As you may recall, there were major breaking changes to the moto library going from 4.x to 5.x. Unfortunately, I'm running into basic issues getting zarr to work with moto. I think I remember you saying that you use moto yourselves for unit testing, so I'm not sure where I'm going wrong. All the tests I've updated are getting the same error:

  File "/blah/blah/blah/lib/python3.12/site-packages/aiobotocore/endpoint.py", line 63, in convert_to_response_dict
    response_dict['body'] = await http_response.content
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: object bytes can't be used in 'await' expression

Steps to reproduce

# /// script
# requires-python = ">=3.12"
# dependencies = [
#     "boto3==1.40.70",
#     "moto==5.1.19",
#     "s3fs==2026.1.0",
#     "zarr==2.18.7",
# ]
# ///
#

import s3fs
from moto import mock_aws
import boto3
import zarr

ma = mock_aws()
ma.start()
bucket_name = "test_bucket"
s3_resource = boto3.resource("s3")
s3_resource.create_bucket(
    Bucket=bucket_name,
    CreateBucketConfiguration={"LocationConstraint": "us-west-2"},
)

s3 = s3fs.S3FileSystem()
store = s3fs.S3Map(root=f"s3://{bucket_name}/my.zarr", s3=s3, check=False)
zarr.open(store, "w")
ma.stop()

Additional output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions