Bird
0
0

Which of the following is the correct syntax to use a single parameter with pytest's @pytest.mark.parametrize decorator?

easy📝 Syntax Q12 of 15
PyTest - Parametrize
Which of the following is the correct syntax to use a single parameter with pytest's @pytest.mark.parametrize decorator?
A@pytest.mark.parametrize('num', 1, 2, 3)
B@pytest.mark.parametrize(num, [1, 2, 3])
C@pytest.mark.parametrize('num', [1, 2, 3])
D@pytest.mark.parametrize(['num'], 1, 2, 3)
Step-by-Step Solution
Solution:
  1. Step 1: Check parameter name format

    The parameter name must be a string inside quotes, e.g., 'num'.
  2. Step 2: Check values format

    The values must be inside a list or iterable, e.g., [1, 2, 3].
  3. Final Answer:

    @pytest.mark.parametrize('num', [1, 2, 3]) -> Option C
  4. Quick Check:

    Parametrize syntax = string + list [OK]
Quick Trick: Parameter name in quotes, values in list brackets [OK]
Common Mistakes:
MISTAKES
  • Not quoting the parameter name
  • Passing values without list brackets
  • Using wrong argument structure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes