Bird
0
0

Why does pytest require test functions to start with 'test_'?

hard🧠 Conceptual Q10 of 15
PyTest - Test Organization
Why does pytest require test functions to start with 'test_'?
ATo allow tests to print output
BTo prevent tests from running accidentally
CTo make test functions run faster
DTo automatically discover and run test functions
Step-by-Step Solution
Solution:
  1. Step 1: Understand pytest test discovery

    Pytest scans files and runs functions starting with 'test_' to find tests automatically.
  2. Step 2: Evaluate other options

    Options B, C, and D do not explain the naming convention purpose correctly.
  3. Final Answer:

    To automatically discover and run test functions -> Option D
  4. Quick Check:

    Test prefix enables automatic discovery [OK]
Quick Trick: Prefix 'test_' lets pytest find your tests automatically [OK]
Common Mistakes:
MISTAKES
  • Thinking prefix controls test speed
  • Assuming prefix prevents accidental runs
  • Believing prefix affects output printing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes