Bird
0
0

Identify the error in this pytest assertion:

medium📝 Debug Q14 of 15
PyTest - Writing Assertions
Identify the error in this pytest assertion:
def test_check():
    y = 10
    assert y > 5 "y should be greater than 5"
AMissing comma between condition and message
BWrong comparison operator
CVariable y is not defined
DMessage should be inside parentheses
Step-by-Step Solution
Solution:
  1. Step 1: Review assert syntax

    Assert statements require a comma between the condition and the message string.
  2. Step 2: Locate the syntax error

    The code misses a comma after y > 5, causing a syntax error.
  3. Final Answer:

    Missing comma between condition and message -> Option A
  4. Quick Check:

    Comma separates assert condition and message [OK]
Quick Trick: Always put a comma before assert message [OK]
Common Mistakes:
MISTAKES
  • Forgetting comma after condition
  • Adding parentheses around message
  • Changing comparison operator unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes