Bird
0
0

Which pytest fixture scope is best when you want to create a Flask test client once per test function?

easy📝 Conceptual Q2 of 15
Flask - Testing Flask Applications
Which pytest fixture scope is best when you want to create a Flask test client once per test function?
Afunction
Bclass
Csession
Dmodule
Step-by-Step Solution
Solution:
  1. Step 1: Recall pytest fixture scopes

    Function scope runs the fixture for each test function.
  2. Step 2: Match scope to test client usage

    Creating a test client per test function ensures isolation.
  3. Final Answer:

    function -> Option A
  4. Quick Check:

    Function scope = per test function [OK]
Quick Trick: Use function scope for fresh setup each test [OK]
Common Mistakes:
MISTAKES
  • Using session scope causes shared state across tests
  • Choosing module scope runs fixture too few times
  • Confusing class scope with function scope

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes