「pytest」の使い方をまとめました。 Python 3.7以降で、以下のコマンドでインストールします。 $ pip install -U pytest pytest-mock pytest-freezegun 3. はじめてのテストの実行 はじめてのテストの実行の手順は、次のとおりです。 (1) Pythonスクリプト「test_sample.py」を作成し ...
# pytest.ini または pyproject.toml で定義 # markers = # slow: 時間がかかるテスト # integration: 統合テスト @pytest.mark.slow def test_heavy_computation(): # 時間がかかる処理 pass @pytest.mark.integration def test_api_integration ...