Bird
0
0

Examine this data-driven test snippet and identify the logical error:

medium📝 Debug Q7 of 15
Selenium Python - Data-Driven Testing
Examine this data-driven test snippet and identify the logical error:
@pytest.mark.parametrize('num', [1, 2, 3])
def test_is_odd(num):
    assert num % 2 == 0
AThe parametrize decorator is missing required arguments
BThe assertion checks for even numbers but the test name implies odd numbers
CThe test function is missing a return statement
DThe list of numbers should be strings, not integers
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the test name

    The function is named test_is_odd, implying it tests for odd numbers.
  2. Step 2: Analyze the assertion

    The assertion assert num % 2 == 0 checks if numbers are even.
  3. Step 3: Identify the mismatch

    The assertion contradicts the test name, causing logical inconsistency.
  4. Final Answer:

    The assertion checks for even numbers but the test name implies odd numbers -> Option B
  5. Quick Check:

    Test name and assertion must align [OK]
Quick Trick: Test name and assertion logic must match [OK]
Common Mistakes:
  • Ignoring mismatch between test name and assertion
  • Assuming parametrize decorator is incorrect
  • Expecting return statements in test functions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes