Qiita Conference 2025

Qiita史上最多!豪華12名のゲストが登壇

特別講演ゲスト(敬称略)

ymrl、成瀬允宣、鹿野壮、伊藤淳一、uhyo、徳丸浩、ミノ駆動、みのるん、桜庭洋之、tenntenn、けんちょん、こにふぁー

3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

motoのバージョン5.x以降のimportエラーについて

Last updated at Posted at 2024-02-12

motoとは?

motoは、AWSの各種サービスをモックするためのPythonライブラリです。
DynamoDBやS3などのマネージドサービスをモックにすることで、実際のAWS環境を用意せずともローカル環境でpytestなどができます。

moto v5系でのDecoratorの変更

そして、いつの間にかmotoのバージョンが5.xに上がりました。
https://docs.getmoto.org/en/5.0.0/docs/releases.html

今回のメジャーアップデートでの注意すべき点は以下です。

All decorators have been replaced with mock_aws

今までは、@mock_s3@mock_dynamodbのようにAWSサービス名でDecoratorを記載していましたが、今後は全て@mock_awsに統一されるとのことです。

これにより今まで作成したpytestをそのままmoto v5系の環境で使おうとすると、import Errorにはまります。

DynamoDB Localを使っている方には影響ありませんが、motoユーザも中々多そうなのでご注意ください。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?