Bird
0
0

What will be the result when running this PyTest test?

medium📝 Predict Output Q13 of 15
PyTest - Basics and Setup
What will be the result when running this PyTest test?
def test_example():
    x = 5
    y = 2
    assert x - y == 3
ATest passes successfully
BSyntaxError occurs
CTest fails with AssertionError
DTest is skipped automatically
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate the assertion expression

    Calculate x - y which is 5 - 2 = 3.
  2. Step 2: Compare with asserted value

    The assertion checks if 3 == 3, which is true, so no error is raised.
  3. Final Answer:

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

    5 - 2 equals 3 means assert passes [OK]
Quick Trick: Calculate assert expression; true means test passes [OK]
Common Mistakes:
MISTAKES
  • Assuming test fails without checking assertion
  • Confusing syntax errors with assertion failures
  • Thinking tests skip without skip decorators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes