Bird
0
0

Identify the error in this pytest code using @pytest.mark.parametrize:

medium📝 Debug Q14 of 15
PyTest - Parametrize
Identify the error in this pytest code using @pytest.mark.parametrize:
@pytest.mark.parametrize('num', [1, 2, 3])
def test_even():
    assert num % 2 == 0
AWrong decorator name
BList of values should be a tuple
CMissing parameter in test function definition
DAssertion logic is incorrect
Step-by-Step Solution
Solution:
  1. Step 1: Check function parameters

    Test function must accept the parameter named in parametrize ('num'), but test_even() has no parameters.
  2. Step 2: Confirm other parts

    Decorator name and list syntax are correct; assertion logic is valid for even check.
  3. Final Answer:

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

    Function must accept parametrize variables [OK]
Quick Trick: Test function needs parameters matching parametrize names [OK]
Common Mistakes:
MISTAKES
  • Forgetting to add parameters to test function
  • Thinking list must be tuple
  • Confusing assertion logic with syntax error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes