Pythonによるテスト入門
Alexander Levin
Data Scientist

連鎖リクエストの利点:
有用な場面:
# 他のフィクスチャから要求されるフィクスチャ
@pytest.fixture
def setup_data():
return "I am a fixture!"
# テスト関数から要求されるフィクスチャ
@pytest.fixture
def process_data(setup_data):
return setup_data.upper()
# テスト関数
def test_process_data(process_data):
assert process_data == "I AM A FIXTURE!"
pytest フィクスチャを用意# 他のフィクスチャを要求するフィクスチャ
@pytest.fixture
def process_data(setup_data):
return setup_data.upper()
Pythonによるテスト入門