Bird
0
0

Which decorator is used in pytest to pass a single parameter to a test function?

easy🧠 Conceptual Q2 of 15
PyTest - Parametrize
Which decorator is used in pytest to pass a single parameter to a test function?
A@pytest.singleparam
B@pytest.mark.parametrize
C@pytest.inputparam
D@pytest.testparam
Step-by-Step Solution
Solution:
  1. Step 1: Recall pytest decorators for parameterization

    pytest uses @pytest.mark.parametrize to pass parameters to test functions.
  2. Step 2: Identify the correct decorator name

    The correct decorator is exactly @pytest.mark.parametrize; others do not exist in pytest.
  3. Final Answer:

    @pytest.mark.parametrize -> Option B
  4. Quick Check:

    Decorator for parameters = @pytest.mark.parametrize [OK]
Quick Trick: Use @pytest.mark.parametrize for single or multiple parameters [OK]
Common Mistakes:
MISTAKES
  • Using non-existent decorators
  • Misspelling the decorator name
  • Confusing with other pytest marks

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes