Skip to content

rednes/introduction-python-lambda-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

introduction-python-lambda-testing

pytestmoto を使って、AWS Lambda(Python)の単体テストを段階的に学ぶチュートリアルです。

詳しくはこちらのブログをご覧ください。

前提条件

  • Python 3.13+
  • uv

主な使用ライブラリ

ライブラリ 用途
pytest テストフレームワーク
pytest-cov カバレッジレポート
moto AWS サービスのモック
responses HTTP リクエストのモック(Chapter 5)

Chapter 一覧

Chapter テーマ
Chapter 1 テスタブルな設計の基本
Chapter 2 依存性注入とモックによるテスト
Chapter 3 リポジトリ層を moto でテストする
Chapter 4 エラーハンドリングとバリデーション
Chapter 5 外部 API 呼び出しのモック

ディレクトリ構成

各 Chapter は独立したプロジェクト(pyproject.toml)として構成されています。

introduction-python-lambda-testing/
├── chapter1/          # テスタブルな設計の基本(カバレッジを含む)
│   ├── pyproject.toml
│   ├── src/
│   └── tests/
├── chapter2/          # 現実的なファイル分割(全層DI・モック)
├── chapter3/          # リポジトリ層をmotoでテストする
├── chapter4/          # エラーハンドリングとバリデーションのテスト
└── chapter5/          # 外部API呼び出しのモック

テストの実行

各 Chapter ディレクトリで以下を実行します。

cd chapterN
uv sync --dev
uv run pytest

GitHub Actions のローカル実行

act を使って、GitHub Actions ワークフローをローカルで実行できます。

# インストール(macOS)
brew install act

# 実行
act push -P ubuntu-slim=catthehacker/ubuntu:act-latest

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages