Bird
0
0

Identify the error in this pytest data provider usage:

medium📝 Debug Q14 of 15
Selenium Python - Data-Driven Testing
Identify the error in this pytest data provider usage:
@pytest.mark.parametrize('input', [1, 2, 3])
def test_example():
    assert input > 0
AWrong decorator name
BMissing parameter in test function definition
CList of inputs should be strings
DAssertion syntax is incorrect
Step-by-Step Solution
Solution:
  1. Step 1: Check test function parameters

    The test function must accept the parameter named in parametrize, here 'input'.
  2. Step 2: Identify missing parameter

    The function test_example() has no parameters, so 'input' is undefined inside it.
  3. Final Answer:

    Missing parameter in test function definition -> Option B
  4. Quick Check:

    Parametrize param must match function argument [OK]
Quick Trick: Function must accept all parametrize arguments [OK]
Common Mistakes:
  • Forgetting to add parameter to test function
  • Using wrong decorator name
  • Thinking input list must be strings
  • Misreading assertion syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes