Bird
0
0

What does the function scope mean for a pytest fixture?

easy🧠 Conceptual Q11 of 15
PyTest - Fixtures
What does the function scope mean for a pytest fixture?
AThe fixture runs once per entire test session.
BThe fixture runs once per test class.
CThe fixture runs once per test module.
DThe fixture runs once per test function.
Step-by-Step Solution
Solution:
  1. Step 1: Understand fixture scopes

    Pytest fixtures can have different scopes controlling how often they run.
  2. Step 2: Define function scope meaning

    Function scope means the fixture runs before each test function and tears down after it.
  3. Final Answer:

    The fixture runs once per test function. -> Option D
  4. Quick Check:

    function scope = runs per test function [OK]
Quick Trick: Function scope means run before every test function [OK]
Common Mistakes:
MISTAKES
  • Confusing function scope with class or module scope
  • Thinking function scope runs once per class
  • Assuming function scope runs once per session

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes