# pytest.ini または pyproject.toml で定義 # markers = # slow: 時間がかかるテスト # integration: 統合テスト @pytest.mark.slow def test_heavy_computation(): # 時間がかかる処理 pass @pytest.mark.integration def test_api_integration ...
「pytest」の使い方をまとめました。 Python 3.7以降で、以下のコマンドでインストールします。 $ pip install -U pytest pytest-mock pytest-freezegun 3. はじめてのテストの実行 はじめてのテストの実行の手順は、次のとおりです。 (1) Pythonスクリプト「test_sample.py」を作成し ...
print関数は引数に渡したものを標準出力に表示する機能がある。 関数`fn`を定義してその中でprint関数を使っているとする。これをtestする方法として`stdout`を監視する方法を考えてみる。しかしこれはprint関数のtestも行っていることになる。 `引数に与えた数 ...