Bird
0
0

Consider this test code:

medium📝 Predict Output Q5 of 15
Testing Fundamentals - Why Software Testing Matters
Consider this test code:
def test_string():
    text = "hello"
    assert text.upper() == "HELLO"

What is the test outcome?
ATest fails because 'hello'.upper() is 'hello'
BTest passes because 'hello'.upper() is 'HELLO'
CTest raises an exception
DTest is ignored
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate the method call

    Calling upper() on 'hello' returns 'HELLO'.
  2. Step 2: Check the assertion

    Assertion compares 'HELLO' == 'HELLO', which is true, so test passes.
  3. Final Answer:

    Test passes because 'hello'.upper() is 'HELLO' -> Option B
  4. Quick Check:

    String upper() returns uppercase, assertion true [OK]
Quick Trick: String.upper() converts to uppercase [OK]
Common Mistakes:
  • Assuming upper() returns lowercase
  • Confusing assertion logic
  • Expecting exceptions incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Testing Fundamentals Quizzes