Bird
0
0

What will happen when running this PyTest test?

medium📝 Predict Output Q5 of 15
PyTest - Basics and Setup
What will happen when running this PyTest test?
def test_fail():
    assert 2 * 2 == 5
ATest is ignored
BTest passes successfully
CTest fails with AssertionError
DSyntax error occurs
Step-by-Step Solution
Solution:
  1. Step 1: Check the assertion condition

    The assertion checks if 2 * 2 equals 5, which is false.
  2. Step 2: Understand PyTest behavior on false assertion

    PyTest raises an AssertionError and marks the test as failed.
  3. Final Answer:

    Test fails with AssertionError -> Option C
  4. Quick Check:

    False assertion means test fails = Test fails with AssertionError [OK]
Quick Trick: False assertions cause test failures [OK]
Common Mistakes:
MISTAKES
  • Assuming test passes without checking assertion
  • Confusing failure with syntax error
  • Thinking tests are ignored automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes