Bird
0
0

Given the code below, what will be the test ID shown for the second test case?

medium📝 Predict Output Q13 of 15
PyTest - Parametrize
Given the code below, what will be the test ID shown for the second test case?
@pytest.mark.parametrize('num', [10, 20], ids=['ten', 'twenty'])
def test_value(num):
    assert num > 5
Atest_value[twenty]
Btest_value[10]
Ctest_value[1]
Dtest_value[20]
Step-by-Step Solution
Solution:
  1. Step 1: Understand how IDs map to test cases

    The ids list assigns 'ten' to the first input (10) and 'twenty' to the second input (20).
  2. Step 2: Identify the second test case ID

    The second test case uses the second ID, which is 'twenty'.
  3. Final Answer:

    test_value[twenty] -> Option A
  4. Quick Check:

    Second ID label = 'twenty' [OK]
Quick Trick: IDs replace values in test names [OK]
Common Mistakes:
MISTAKES
  • Assuming default numeric index is used
  • Confusing value with ID label
  • Ignoring the IDs parameter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes