Bird
0
0

Given this pytest data-driven test snippet, what will be the output if the test fails for input 3?

medium📝 Predict Output Q13 of 15
Selenium Python - Data-Driven Testing
Given this pytest data-driven test snippet, what will be the output if the test fails for input 3?
import pytest

@pytest.mark.parametrize('num', [1, 2, 3])
def test_is_even(num):
    assert num % 2 == 0
ATest fails only for input 3
BTest fails for inputs 1 and 3
CTest passes for all inputs
DTest fails for input 2 only
Step-by-Step Solution
Solution:
  1. Step 1: Understand the test logic

    The test asserts num % 2 == 0, meaning num must be even.
  2. Step 2: Check each input

    Input 1: 1 % 2 = 1 (fail), Input 2: 2 % 2 = 0 (pass), Input 3: 3 % 2 = 1 (fail).
  3. Final Answer:

    Test fails for inputs 1 and 3 -> Option B
  4. Quick Check:

    Odd numbers fail assertion [OK]
Quick Trick: Even numbers pass; odd numbers fail [OK]
Common Mistakes:
  • Assuming only input 3 fails
  • Thinking all inputs pass
  • Confusing modulo operation results

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes