Bird
0
0

Which of the following is the correct way to name a test file so pytest can discover it automatically?

easy📝 Syntax Q12 of 15
PyTest - Basics and Setup
Which of the following is the correct way to name a test file so pytest can discover it automatically?
Atest_example.py
Bmytests.py
Cexample.py
DTestExample.py
Step-by-Step Solution
Solution:
  1. Step 1: Recall pytest naming rules

    pytest discovers test files that start with test_ or end with _test.py.
  2. Step 2: Check each option

    test_example.py starts with test_, so pytest will find it automatically.
  3. Final Answer:

    test_example.py -> Option A
  4. Quick Check:

    File starts with test_ = discovered [OK]
Quick Trick: Name test files starting with test_ for pytest discovery [OK]
Common Mistakes:
MISTAKES
  • Naming files without test_ prefix
  • Using uppercase letters at start
  • Assuming pytest finds any .py file

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes