To run once per test class automatically, scope='class' and autouse=True are needed.
Step 2: Check other options
@pytest.fixture(scope='function', autouse=True)
def setup_class():
return 'resource' uses function scope (runs per test), C disables autouse, and D uses default function scope.
Final Answer:
@pytest.fixture(scope='class', autouse=True)\ndef setup_class():\n return 'resource' -> Option A
Quick Check:
Use scope='class' with autouse=True for class-level automatic fixture [OK]
Quick Trick:Use scope='class' and autouse=True for class-level automatic fixture [OK]
Common Mistakes:
MISTAKES
Using function scope for class-level setup
Forgetting autouse=True for automatic run
Confusing module and class scopes
Master "Fixtures" in PyTest
9 interactive learning modes - each teaches the same concept differently