Bird
0
0

Given this data-driven test snippet, what will be the output if the test runs with inputs [2, 4, 6] and asserts input % 2 == 0?

medium📝 Predict Output Q4 of 15
Selenium Python - Data-Driven Testing
Given this data-driven test snippet, what will be the output if the test runs with inputs [2, 4, 6] and asserts input % 2 == 0? ```python @pytest.mark.parametrize('num', [2, 4, 6]) def test_even(num): assert num % 2 == 0 ```
ATest run will error due to syntax mistake
BAll tests fail because the assertion is incorrect
CAll tests pass because all inputs are even numbers
DOnly the test with input 2 passes
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the inputs and assertion

    Inputs are 2, 4, and 6. The assertion checks if each number is even (num % 2 == 0).
  2. Step 2: Evaluate assertion for each input

    2 % 2 == 0 (true), 4 % 2 == 0 (true), 6 % 2 == 0 (true). All pass.
  3. Final Answer:

    All tests pass because all inputs are even numbers -> Option C
  4. Quick Check:

    All inputs even = All assertions true = Pass [OK]
Quick Trick: Check each input against assertion carefully [OK]
Common Mistakes:
  • Assuming some inputs fail without checking
  • Confusing assertion logic
  • Thinking syntax error exists when it doesn't

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes