Bird
0
0

What test ID will pytest display for the second test case in this code?

medium📝 Predict Output Q4 of 15
PyTest - Parametrize
What test ID will pytest display for the second test case in this code?
@pytest.mark.parametrize('value', [100, 200], ids=['hundred', 'two_hundred'])
def test_value(value):
    assert value > 50
A1
Btwo_hundred
Cvalue[1]
D200
Step-by-Step Solution
Solution:
  1. Step 1: Understand ids mapping

    The ids list assigns names to each parameter set in order.
  2. Step 2: Identify second test case ID

    The second test case corresponds to the second ID: 'two_hundred'.
  3. Final Answer:

    two_hundred -> Option B
  4. Quick Check:

    IDs correspond positionally to parameters [OK]
Quick Trick: IDs list matches parameters by position [OK]
Common Mistakes:
MISTAKES
  • Assuming numeric IDs are default
  • Using parameter value as ID automatically
  • Confusing index with ID string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes