Bird
0
0

What will be the result of running this pytest test function?

medium📝 Predict Output Q13 of 15
PyTest - Test Organization
What will be the result of running this pytest test function?
def test_sum():
    result = 2 + 3
    assert result == 5
ATest passes successfully
BTest fails with AssertionError
CSyntaxError occurs
DTest is skipped automatically
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the test code

    The function calculates 2 + 3 and stores in 'result'.
  2. Step 2: Check the assertion

    The assertion checks if 'result' equals 5, which is true.
  3. Final Answer:

    Test passes successfully -> Option A
  4. Quick Check:

    2 + 3 == 5 means test passes [OK]
Quick Trick: If assert condition is true, test passes [OK]
Common Mistakes:
MISTAKES
  • Assuming assertion fails when it is true
  • Confusing syntax errors with assertion errors
  • Thinking tests skip without skip decorators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes