Bird
0
0

Given this fixture factory and test, what will be the output?

medium📝 Predict Output Q4 of 15
PyTest - Fixtures
Given this fixture factory and test, what will be the output? ```python import pytest @pytest.fixture def multiply_factory(): def multiply(x, y): return x * y return multiply def test_multiply(multiply_factory): assert multiply_factory(3, 4) == 12 ```
ASyntax error due to fixture misuse
BTest fails with assertion error
CRuntime error: multiply_factory is not callable
DTest passes successfully
Step-by-Step Solution
Solution:
  1. Step 1: Understand fixture factory usage

    The fixture returns a function multiply that takes two arguments and returns their product.
  2. Step 2: Analyze test assertion

    The test calls multiply_factory(3, 4) which returns 12, matching the assertion.
  3. Final Answer:

    Test passes successfully -> Option D
  4. Quick Check:

    Fixture factory returns callable = test passes [OK]
Quick Trick: Fixture factory returns callable used in test [OK]
Common Mistakes:
MISTAKES
  • Assuming fixture returns value directly, not function
  • Confusing fixture name with function call
  • Expecting errors from correct fixture usage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes