The scope value 'modul' is misspelled; correct is 'module'.
Step 2: Understand effect of typo
Pytest will not recognize the scope and may default or error, causing fixture not to run properly.
Final Answer:
Typo in scope value causes fixture not to run. -> Option B
Quick Check:
Scope must be spelled correctly [OK]
Hint: Check scope spelling carefully to avoid errors [OK]
Common Mistakes:
Assuming fixture must return a value
Confusing fixture decorator with marker
Ignoring spelling errors in parameters
5. You want a pytest fixture to initialize a database connection once before all tests in multiple modules run, and close it after all tests finish. Which scope should you use and why?
hard
A. Use session scope to share across all tests in the run.
B. Use function scope to isolate each test.
C. Use module scope to share per file.
D. Use class scope to share per test class.
Solution
Step 1: Understand the requirement
The database connection should be initialized once before all tests in multiple modules and closed after all tests.
Step 2: Match scope to requirement
Session scope runs once per entire test session, perfect for setup/teardown across all modules.
Final Answer:
Use session scope to share across all tests in the run. -> Option A
Quick Check:
Session scope = once per test run [OK]
Hint: Session scope runs once for all tests in the run [OK]
Common Mistakes:
Choosing function or class scope which run too often
Using module scope which limits to one file
Not matching scope to resource lifetime
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.