Bird
0
0

A test function is named Test_total() inside test_summary.py. Pytest does not run it. What is the most likely reason?

medium📝 Debug Q7 of 15
PyTest - Basics and Setup
A test function is named Test_total() inside test_summary.py. Pytest does not run it. What is the most likely reason?
AFile name does not start with 'test_'
BFunction name starts with uppercase 'T' instead of lowercase 'test_'
CFunction is missing a return statement
DPytest requires test functions to be inside classes
Step-by-Step Solution
Solution:
  1. Step 1: Check file name

    test_summary.py is a valid test file name.
  2. Step 2: Check function name

    The function is named Test_total() with uppercase 'T' at the start, which does not match pytest's required lowercase test_ prefix.
  3. Step 3: Pytest discovery rules

    Pytest only discovers functions starting exactly with lowercase test_.
  4. Final Answer:

    Function name starts with uppercase 'T' instead of lowercase 'test_' -> Option B
  5. Quick Check:

    Function names must start with lowercase 'test_' [OK]
Quick Trick: Function names must start with lowercase 'test_' [OK]
Common Mistakes:
MISTAKES
  • Using uppercase 'Test' prefix
  • Assuming pytest ignores case in function names
  • Expecting pytest to run functions without 'test_' prefix

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes