Bird
0
0

Which of the following is the correct syntax to combine two @pytest.mark.parametrize decorators for parameters x and y?

easy📝 Syntax Q12 of 15
PyTest - Parametrize
Which of the following is the correct syntax to combine two @pytest.mark.parametrize decorators for parameters x and y?
A@pytest.mark.parametrize(['x', 'y'], [1, 2], [3, 4]) def test_func(x, y): pass
B@pytest.mark.parametrize('x, y', [(1, 3), (2, 4)]) def test_func(x, y): pass
C@pytest.mark.parametrize('x', [1, 2], 'y', [3, 4]) def test_func(x, y): pass
D@pytest.mark.parametrize('x', [1, 2]) @pytest.mark.parametrize('y', [3, 4]) def test_func(x, y): pass
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax for multiple parametrize decorators

    Each decorator takes one parameter name string and a list of values.
  2. Step 2: Verify correct usage

    @pytest.mark.parametrize('x', [1, 2]) @pytest.mark.parametrize('y', [3, 4]) def test_func(x, y): pass correctly uses two separate decorators, each with one parameter and its values.
  3. Final Answer:

    Two separate @pytest.mark.parametrize decorators, one for each parameter. -> Option D
  4. Quick Check:

    Separate decorators, one param each = correct syntax [OK]
Quick Trick: Use separate decorators for each param list [OK]
Common Mistakes:
MISTAKES
  • Trying to pass multiple params in one decorator incorrectly
  • Using wrong argument formats
  • Combining parameters in one decorator without tuples

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes