Bird
0
0

Which Python syntax correctly defines a data-driven test using pytest's parametrize decorator?

easy📝 Syntax Q3 of 15
Selenium Python - Data-Driven Testing
Which Python syntax correctly defines a data-driven test using pytest's parametrize decorator?
A@pytest.mark.parametrize('input', [1, 2, 3])\ndef test_example(input):\n assert input > 0
B@pytest.parametrize('input', [1, 2, 3])\ndef test_example(input):\n assert input > 0
C@pytest.mark.parametrized('input', [1, 2, 3])\ndef test_example(input):\n assert input > 0
D@pytest.mark.parametrize('input')\ndef test_example(input):\n assert input > 0
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct pytest parametrize syntax

    The correct decorator is @pytest.mark.parametrize with two arguments: parameter name and list of values.
  2. Step 2: Check each option

    @pytest.mark.parametrize('input', [1, 2, 3])\ndef test_example(input):\n assert input > 0 uses correct spelling and arguments. Others have typos or missing arguments.
  3. Final Answer:

    @pytest.mark.parametrize('input', [1, 2, 3])\ndef test_example(input):\n assert input > 0 -> Option A
  4. Quick Check:

    Correct decorator spelling and arguments = @pytest.mark.parametrize('input', [1, 2, 3])\ndef test_example(input):\n assert input > 0 [OK]
Quick Trick: Use @pytest.mark.parametrize with parameter and list [OK]
Common Mistakes:
  • Misspelling 'parametrize' as 'parameterize' or 'parametrized'
  • Omitting the list of values argument
  • Using wrong decorator syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes