こんにちは!Pytestのfixtureをシェアします。 テスト関数の引数にfixture名を書くだけで、自動的に値が渡されます。 複数のテストファイルでfixtureを共有したい場合は、conftest.pyに定義します: # conftest.py import pytest @pytest.fixture def common_data(): return {"version": "1.0 ...
# pytest.ini [pytest] # テストディレクトリ testpaths = tests # Pythonパス pythonpath = src # マーカー定義 markers = slow: 時間がかかるテスト integration: 統合テスト unit: 単体テスト # 実行オプション addopts = -v --strict-markers --cov=src ...
筒井 (@ryu22e) です。今月の 「Python Monthly Topics」 は、Web APIのテストデータを自動生成してくれるツール 「Schemathesis(スキーマセシス) 」 を紹介します。 Schemathesisとは何か Schemathesisは、OpenAPIまたはGraphQLで書かれたAPI仕様を元にテストデータを自動生成し ...