Bird
0
0

Identify the error in this pytest code using a single parameter:

medium📝 Debug Q14 of 15
PyTest - Parametrize
Identify the error in this pytest code using a single parameter:
import pytest

@pytest.mark.parametrize('val', 1, 2, 3)
def test_positive(val):
    assert val > 0
AParameter name should not be in quotes
BMissing list brackets around parameter values
CTest function must have two parameters
DAssertion should use == instead of >
Step-by-Step Solution
Solution:
  1. Step 1: Check parametrize values format

    Values must be inside a list or iterable, e.g., [1, 2, 3].
  2. Step 2: Identify missing brackets

    Code passes values as separate arguments instead of a single list, causing syntax error.
  3. Final Answer:

    Missing list brackets around parameter values -> Option B
  4. Quick Check:

    Values need list brackets [OK]
Quick Trick: Values must be in a list or tuple [OK]
Common Mistakes:
MISTAKES
  • Passing values without brackets
  • Removing quotes from parameter name
  • Wrong assertion operator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes