Bird
0
0

What will be the output of the following pytest test using data providers?

medium📝 Predict Output Q13 of 15
Selenium Python - Data-Driven Testing
What will be the output of the following pytest test using data providers?
import pytest

@pytest.mark.parametrize('num', [1, 2, 3])
def test_is_positive(num):
    assert num > 0
AAll tests pass
BAll tests fail
COnly the test with num=1 passes
DSyntax error occurs
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the test logic

    The test asserts that the input number is greater than zero.
  2. Step 2: Check each data value

    Values 1, 2, and 3 are all greater than zero, so all assertions pass.
  3. Final Answer:

    All tests pass -> Option A
  4. Quick Check:

    All nums > 0, so tests pass [OK]
Quick Trick: Check if all inputs satisfy the assertion [OK]
Common Mistakes:
  • Assuming some inputs fail without checking values
  • Thinking syntax error due to parametrize
  • Ignoring that all numbers are positive

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes