サービス
サービスを探す
プロ人材を探す
仕事を探す
ブログを探す
@pytest.fixture
def 関数1():
set up の処理
yield テスト関数に渡す値
tear down の処理
...
def テスト関数(関数1, ...):
関数1から渡された値を使ったテスト
set upとtear downを1つの関数にして、テスト関数に渡す
渡す関数に @pytest.fixture をつける
渡す関数は複数でもいい
※ @は小文字
@pytest.fixture
def 関数():
set up の処理
yield
tear down の処理
@pytest.fixture(autouse=True)
def 関数():
set up の処理
yield
tear down の処理
※ @は小文字
①autouse=True を指定したset up
②関数に引数として渡した順
set upの逆