Bird
0
0

Find the error in this PyTest test:

medium📝 Debug Q7 of 15
PyTest - Basics and Setup
Find the error in this PyTest test:
def test_check():
assert 1 == 1
ATest function missing return statement
BFunction name is invalid
CMissing parentheses in assert
DIndentation error: assert must be indented inside function
Step-by-Step Solution
Solution:
  1. Step 1: Check indentation inside function

    Python requires the assert statement to be indented inside the function block.
  2. Step 2: Validate other options

    Function name is valid, assert does not need parentheses, and return is optional in tests.
  3. Final Answer:

    Indentation error: assert must be indented inside function -> Option D
  4. Quick Check:

    Indent assert inside function = Indentation error: assert must be indented inside function [OK]
Quick Trick: Indent code inside functions properly [OK]
Common Mistakes:
MISTAKES
  • Not indenting code inside functions
  • Thinking assert needs parentheses
  • Expecting return statements in tests

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes