Bird
0
0

Consider this pytest test using data providers:

medium📝 Predict Output Q5 of 15
Selenium Python - Data-Driven Testing
Consider this pytest test using data providers:
import pytest

@pytest.mark.parametrize('input,expected', [(2,4), (3,9)])
def test_square(input, expected):
    assert input ** 2 == expected

What happens if you add a third tuple (4, 15) to the list?
AThe third test fails because 4 squared is 16, not 15
BAll tests pass because 15 is close to 16
CSyntax error due to extra tuple
DTest runner skips the third tuple silently
Step-by-Step Solution
Solution:
  1. Step 1: Understand the test logic

    Test checks if input squared equals expected value.
  2. Step 2: Evaluate third tuple

    4 squared is 16, but expected is 15, so assertion fails.
  3. Final Answer:

    The third test fails because 4 squared is 16, not 15 -> Option A
  4. Quick Check:

    Incorrect expected value causes test failure [OK]
Quick Trick: Check expected values carefully; wrong expected causes failure [OK]
Common Mistakes:
  • Assuming close values pass assertions
  • Thinking extra tuples cause syntax errors
  • Believing pytest skips failing data silently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes