Bird
0
0

Which of the following file names will pytest recognize as a test file by default?

easy🧠 Conceptual Q11 of 15
PyTest - Test Organization
Which of the following file names will pytest recognize as a test file by default?
Aexample.py
Btest_example.py
Cexample_test.pyc
DTestExample.py
Step-by-Step Solution
Solution:
  1. Step 1: Understand pytest file naming rules

    pytest looks for files starting or ending with 'test' and ending with '.py'.
  2. Step 2: Check each option

    'test_example.py' starts with 'test' and ends with '.py', so pytest will find it. Others either don't end with '.py' or don't start/end with 'test'.
  3. Final Answer:

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

    File starts or ends with 'test' + '.py' = test_example.py [OK]
Quick Trick: Test files start or end with 'test' and end with '.py' [OK]
Common Mistakes:
MISTAKES
  • Thinking pytest finds .pyc files
  • Ignoring case sensitivity in file names
  • Assuming any .py file is a test file

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes