Bird
0
0

You have tests in 'tests/' and 'tests/utils/'. Running 'pytest tests/' misses tests in 'utils'. What is the likely cause?

medium📝 Debug Q6 of 15
PyTest - Test Organization
You have tests in 'tests/' and 'tests/utils/'. Running 'pytest tests/' misses tests in 'utils'. What is the likely cause?
A'utils' folder lacks an __init__.py file
BTest files in 'utils' don't start with 'test_'
CPytest cannot run tests in subfolders
DTests in 'utils' have no assertions
Step-by-Step Solution
Solution:
  1. Step 1: Understand pytest discovery rules

    Pytest finds tests in files starting with 'test_'.
  2. Step 2: Identify cause of missing tests

    If 'utils' test files don't start with 'test_', pytest skips them.
  3. Final Answer:

    Test files in 'utils' don't start with 'test_' -> Option B
  4. Quick Check:

    Test file prefix 'test_' required for discovery [OK]
Quick Trick: Name test files starting with 'test_' to be found [OK]
Common Mistakes:
MISTAKES
  • Thinking __init__.py is required for pytest discovery
  • Believing pytest can't run tests in subfolders
  • Assuming missing assertions cause tests to be skipped

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes