Step 1: Check the use of @pytest.fixture decorator
The @pytest.fixture decorator is required to mark a fixture. One option lacks it.
Step 2: Identify correct use of yield for setup and teardown
@pytest.fixture
def client():
app = Flask(__name__)
yield app.test_client() uses yield to provide the test client and allows cleanup after tests, which is best practice.
Final Answer:
@pytest.fixture\ndef client():\n app = Flask(__name__)\n yield app.test_client() -> Option A
Quick Check:
Use @pytest.fixture and yield for fixtures [OK]
Quick Trick:Use @pytest.fixture and yield to define fixtures [OK]
Common Mistakes:
MISTAKES
Omitting @pytest.fixture decorator
Returning instead of yielding
Not yielding or returning the test client
Master "Testing Flask Applications" in Flask
9 interactive learning modes - each teaches the same concept differently