Python CodeとTest Code作成の備忘録
1.仮想環境の作成python -m venv 作成するフォルダ名
-mオプションPythonの内部機能を直接呼び出す。
2.Python CodeとTest Codeの作成
main.py
#Python Code
def add(a, b):
return a + b
test.py
#Test Code
from main import add
def test_add():
assert add(1,2) == 3
def test_add():
assert add(-1,1) == 0
3.Pytestをインストールpip install pytest
4.test実行pytest