Bird
0
0

Consider this conftest.py fixture:

medium📝 Predict Output Q5 of 15
PyTest - Test Organization
Consider this conftest.py fixture:
import pytest

@pytest.fixture(scope="module")
def config():
    return {"url": "http://test"}

What is the effect of the scope="module" parameter?
AFixture is created once per test function
BFixture is created once per test session
CFixture is created once per test module
DFixture is created once per test class
Step-by-Step Solution
Solution:
  1. Step 1: Understand fixture scopes in pytest

    Scope "module" means the fixture is created once for all tests in a single Python module (file).
  2. Step 2: Match scope to options

    Fixture is created once per test module correctly states creation once per test module.
  3. Final Answer:

    Fixture is created once per test module -> Option C
  4. Quick Check:

    Scope module = once per file [OK]
Quick Trick: Use scope='module' for one fixture per test file [OK]
Common Mistakes:
MISTAKES
  • Confusing module scope with function or session
  • Assuming scope='module' means per class
  • Ignoring scope parameter effects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes