Bird
0
0

Identify the error in this pytest code:

medium📝 Debug Q6 of 15
PyTest - Parametrize
Identify the error in this pytest code:
import pytest

@pytest.mark.parametrize('value', [10, 20])
def test_value(value):
print(value)
    assert value > 0
AMissing parameter name in decorator
BInvalid parameter list format
CIncorrect assert syntax
DIndentation error on print statement
Step-by-Step Solution
Solution:
  1. Step 1: Check indentation of code inside function

    Python requires consistent indentation. The print statement is not indented properly under the function.
  2. Step 2: Verify other parts of the code

    Decorator and assert syntax are correct; parameter list format is valid.
  3. Final Answer:

    Indentation error on print statement -> Option D
  4. Quick Check:

    Python code blocks need proper indentation [OK]
Quick Trick: Indent all code inside functions consistently [OK]
Common Mistakes:
MISTAKES
  • Ignoring indentation errors
  • Assuming decorator syntax is wrong
  • Misreading assert statement

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes