Python เบื้องต้นสำหรับการทดสอบโค้ด
Alexander Levin
Data Scientist

การเชื่อมต่อคำขอ fixture ช่วยให้:
เหมาะใช้เมื่อ:
# Fixture that is requested by the other fixture
@pytest.fixture
def setup_data():
return "I am a fixture!"
# Fixture that is requested by the test function
@pytest.fixture
def process_data(setup_data):
return setup_data.upper()
# The test function
def test_process_data(process_data):
assert process_data == "I AM A FIXTURE!"
pytest# Fixture requesting other fixture
@pytest.fixture
def process_data(setup_data):
return setup_data.upper()
Python เบื้องต้นสำหรับการทดสอบโค้ด